Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
103 stars 47 forks source link

allOf merging of types does not work #239

Open konarskis opened 5 months ago

konarskis commented 5 months ago

Steps to reproduce

Try generating the code with the provided snippet.

Expected results

It's expected that the types will be merged into new types with autogenerated names possibly.

Actual results

Instead, the generated type is just 'dynamic'.

Your OpenApi snippet

    Overview:
      type: object
      properties:
        pets:
          type: array
          items:
            type: object
            allOf:
              - $ref: '#/components/schemas/Pet'
              - type: object
                properties:
                  trackers:
                    type: array
                    items:
                      type: object
                      allOf:
                        - $ref: '#/components/schemas/Tracker'
                        - type: object
                          properties:
                            events:
                              type: array
                              items:
                                $ref: '#/components/schemas/Event'
                          required:
                            - events
                required:
                  - trackers
      required:
        - pets

Code sample

No response

Logs

No response

Dart version and used packages versions

3.4.3 ```console dart run swagger_parser ```
18.0 ```console dart run swagger_parser ```
BreSmit521 commented 4 months ago

Running into this as well, any luck finding a workaround?

ASKabanets commented 2 months ago

Faced the same, here's the specs example:

  /browse-sections:
    post:
      operationId: browse-sections
      requestBody:
        content:
          application/json:
            schema:
              required:
                - query
                - navigation
              properties:
                query:
                  type: object
                  properties:
                    location:
                      properties:
                        id:
                          type: string
                    search:
                      type: string
                navigation:
                  allOf:
                    - $ref: '#/components/schemas/value.navigation'
                    - properties:
                        sort:
                          allOf:
                            - $ref: '#/components/schemas/value.sort'
                            - type: object
                              properties:
                                key:
                                  type: string
                                  enum: [ name, description, createDate ]
                                  example: name
                                order:
                                  type: string
                                  enum: [ ASC, DESC ]
                                  example: 'ASC'
      responses:
        200:
          content:
            application/json:
              schema:
                properties:
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        section:
                          $ref: '#/components/schemas/section.browse'
                  page:
                    $ref: '#/components/schemas/value.page'
        400:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/value.error'
          description: Bad content
        401:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/value.error'
          description: Unauthorized
        500:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/value.error'
          description: Server error

And this part is generated with dynamic types:

 /// Browse sections
  @POST('/browse-sections')
  Future<dynamic> postBrowseSections({
    @Body() dynamic body,
  });