Skip to content

Stop generating an undocumented case for enums/oneOfs #204

@czechboy0

Description

@czechboy0

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.

Metadata

Metadata

Assignees

Labels

area/openapiAdding/updating a feature defined in OpenAPI.kind/bugFeature doesn't work as expected.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions