Skip to content

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

Description

@gawi151

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 ;)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions