Closed niklassaers closed 1 month ago
Hi @niklassaers,
I think the issue here is that you have schemas that try to be both an object and an allOf. But that won't work here.
Try to fix this by updating RootType
to:
RootType:
allOf:
- $ref: "#/components/schemas/BaseWithModulesType"
- type: object
required:
- type
properties: ...
Basically, move the attributes of the object
schema into a second subschema of the allOf
.
And in BaseWithModulesType
, you can remove discriminator
- that's only used with oneOf
s.
Hi @czechboy0, thank you very much for your quick response. Thank you also a ton for pointing out the mistake in how to use allOf with an object, none of the validators that I had used had picked up on that and I thought it was correct. I've corrected that now, and that works beautifully.
Question
Hi, first of all thank you so much for making and maintaining this project :-)
I have an issue that when I have a component whos schema includes an allOf and properties, the properties don't appear in the code. As soon as I remove the allOf, the new properties are back. What can I do to get both the inherited and the new properties?
In my example, I have a super component
BaseType
that has a specialisationBaseWithModulesType
. Then I have the type that I expect to return from my API which isRootType
that is aBaseWithModulesType
plus a few properties. RootType has a unique propertymoreModules
but that one never appears in the generated Swift codeHere is the YAML in question:
So my test for this could be: Given that "swift-openapi-generator generate" is called with the OpenAPI document above, does "moreModules" appear in
Types.swift
?Is there anything I can do already to make "moreModules" appear? :-) Perhaps there's some way I can format the OpenAPI? The source OpenAPI document uses allOf with BaseType and BaseWithModulesType a lot, so I don't think duplicating the properties around is an option.