Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RReverser opened this issue Aug 19, 2024 · 0 comments
Open

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

RReverser opened this issue Aug 19, 2024 · 0 comments

Comments

@RReverser
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant