oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

The decriminator is set only if the "mapping" field is present

Open Antonboom opened this issue 1 year ago • 1 comments

Related to https://github.com/deepmap/oapi-codegen/pull/471

Hello!

mapping field is useful for explicit mapping:

In scenarios where the value of the discriminator field does not match the schema name or implicit mapping is not possible, an optional mapping definition MAY be used

But by default I expected the generated code to set the descriminator field by schema name:

The expectation now is that a property with name petType MUST be present in the response payload, and the value will correspond to the name of a schema defined in the OAS document.

MyResponseType:
  oneOf:
  - $ref: '#/components/schemas/Cat'
  - $ref: '#/components/schemas/Dog'
  - $ref: '#/components/schemas/Lizard'
  discriminator:
    propertyName: petType

But now it doesn't work like that. Thanks.

Antonboom avatar Aug 09 '22 04:08 Antonboom

@jamietanna @deepmap-marcinr @Warboss-rus FYI

Antonboom avatar Jan 22 '23 14:01 Antonboom