cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Does interface extends OR union type work in 0.20.0 #202

Closed malvin-metamatics closed 2 years ago

malvin-metamatics commented 2 years ago

Hello together, having an allOf in the input schema:

"SpecificDTO": {
    "type": "object",
    "allOf": [
        {
            "$ref": "#/components/schemas/AbstractDTO"
        }
    ]
},

I expect the result to be:

interface SpecificDTO extends AbstractDTO

or a similar solution using union types (having read a couple of issues and PRs here).

For me it seems I can not do that. Can you tell me if it is possible or not?

Thanks a lot in advance!

malvin-metamatics commented 2 years ago

I found the reason for it. When I use the following definition:

"SpecificDTO": {
    "type": "object",
    "allOf": [
        {
            "$ref": "#/components/schemas/AbstractDTO"
        }
    ]
},

it does NOT work because of the "type": "object"

When I remove the type it works as expected. But I see not why it changes the behavior. Any ideas?

luisfpg commented 2 years ago

It is an invalid definition to have both type:object and allOf. The generator could either break or decide which one to follow.