-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Consider not generating an undocumented case for enums/oneOfs by default.
It seemed like a good idea to generate the undocumented case before, as it allows for API evolution - as adding an enum or oneOf case maybe shouldn't be a breaking change.
However, OpenAPI/JSON Schema enums/oneOfs are closed by default, so we're actually diverging from the specification here.
And it's causing issues when these enums/oneOfs are nested within other allOfs/oneOfs/anyOfs and it "successfully" parses even though it parses into an undocumented case.
Talk about this more, but we might need to undo this, and follow the specification closely, and also generate closed enums by default. Possibly it could be an option to generate an undocumented case? Or we should document that open enums can be represented as:
MyOpenEnum:
anyOf:
- type: string
enum:
- foo
- bar
- baz
- type: string
And an open oneOf with:
MyOpenOneOf:
anyOf:
- oneOf:
- #/components/schemas/Foo
- #/components/schemas/Bar
- #/components/schemas/Baz
- {}
And as an adopter, you first check the first schema if it's not nil. If it's not nil, the closed enum/oneOf parsed successfully. If the first element is nil, the second will be filled in, which is the fallback value.