yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator
MIT License
627 stars 147 forks source link

Support for allOf #170

Closed kroegerama closed 5 years ago

kroegerama commented 5 years ago

Is there any support for allOf planned? The generated code for PushPaginated does not correctly inherit from the referenced types.

Pagination:
      type: object
      properties:
        draw:
          type: integer
        recordsTotal:
          type: integer
          format: int64
        recordsFiltered:
          type: integer
          format: int64
        error:
          type: string
      required:
        - draw
        - recordsTotal
        - recordsFiltered
PushItem:
      type: object
      properties:
        title:
          type: string
        subtitle:
          type: string
        content:
          type: string
PushPaginated:
      type: object
      allOf:
        - $ref: '#/components/schemas/Pagination'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/PushItem'
yonaskolb commented 5 years ago

Hi @kroegerama. allOf is supported. In your case just remove the type: object from PushPaginated and it should work. Let me know how you go

kroegerama commented 5 years ago

Thank you so much! Works fine now :)

haemi commented 5 years ago

but does this also work with structs? Inheritance is not possible there...

And what happens for something like this?

SomethingAndSomethingelse:
     allOf:
     - $ref: ‘#/components/schemas/Something’
     - $ref: ‘#/components/schemas/SomethingElse’

multiple inheritance is even less possible...

yonaskolb commented 5 years ago

Structs will get the properties of both

haemi commented 5 years ago

currently I get

public struct SomethingAndSomethingelse: Something {

with the error Inheritance from non-protocol type 'Something'

yonaskolb commented 5 years ago

Have you set the template property modelInheritance to false and the modelType to struct?

haemi commented 4 years ago

yes; with modelInheritance false it works, but only the first reference is used, the SomethingElse is ignored...