Skip to content

Support enums with descriptions as per OpenAPI v3.1 #10104

Open
@RReverser

Description

@RReverser

Content & configuration

Swagger/OpenAPI definition:

cvv_check:
 type: string
 title: CVV check
 description: When processed, result from checking the CVV/CVC value on the transaction.
 oneOf:
   - const: D
     description: Suspicious transaction
   - const: I
     description: Failed data validation check
   - const: M
     description: Match
   - const: N
     description: No Match
   - const: P
     description: Not Processed
   - const: S
     description: Should have been present
   - const: U
     description: Issuer unable to process request
   - const: X
     description: Card does not support verification

Is your feature request related to a problem?

Previous versions of OpenAPI didn't allow declaring enums with custom titles and descriptions, making it hard to describe formats that use integer as underlying enum representation.

Starting with OpenAPI v3.1, which has oneOf and other combinatorial operators, the officially recommended approach is to use YAML like above that combines oneOf + list of consts into essentially an enum with named items.

SwaggerUI can show this schema as expected, but the "Try it out" editor still shows such fields as simple text inputs with no validation.

Describe the solution you'd like

Such fields should be rendered as dropdowns that show list of human-readable names (title), shows description on hover, and actually translates to the underlying const as the value passed in the form.

Basically, it should behave in the same way as enum does, except for mapping values to their human-readable names.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions