tazatechnology / openapi_spec

Dart based OpenAPI specification generator and parser
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

`allOf` schemas are not added in the final generated class #71

Open gawi151 opened 4 weeks ago

gawi151 commented 4 weeks ago

Hey there I want to generate a client with your amazing package. I encountered a problem with allOf definition where you can have multiple schemas references or even have an in place object there with properties.

You have an example of such schema in petstore-expanded.yaml

components:
  schemas:
    Pet:
      allOf:
        - $ref: '#/components/schemas/NewPet'
        - type: object
          required:
          - id
          properties:
            id:
              type: integer
              format: int64

    NewPet:
      type: object
      required:
        - name  
      properties:
        name:
          type: string
        tag:
          type: string    

So in this case Pet should contain all of props from NewPet and prop id in it.

Pseudocode for visualisation of expected result (in the end it should be freezed generated class)

class Pet {
  final int id;
  final String name;
  final String? tag;

  Pet({
    required this.id,
    required this.name,
    this.tag,
  })
}

At the moment I don't see support for that. I'm trying to figure out where is the best place to handle dereferencing the allOf + working with in-place schemas. As of now I think SchemaGenerator._writeObject is the place it should be handled but dunno yet.

I'd appreciate any feedback on this problem and maybe some guidance how to make it work ;)