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

Handle const like enum with --const-as-enum option #2073

Closed

Conversation

vladimir-prisada
Copy link

Closes #1899

@arthurfiorette
Copy link
Collaborator

cant we settle on a default behavior that works for everyone? I dont like the approach of adding a new option just for this. Seems like trivial information that is hard to teach via documentation that if used incorrectly will lead to unexpected behavior.

@domoritz
Copy link
Member

Yes, let's not add a config option.

@vladimir-prisada
Copy link
Author

vladimir-prisada commented Sep 17, 2024

So, you prefer to make it as a default behavior (instead of "const" always use "enum" with single value), could it be a breaking change for current users? Probably, somebody needs to have a "const" in their schema...

@arthurfiorette
Copy link
Collaborator

whats the preferred way according to openapi spec?

@vladimir-prisada
Copy link
Author

"const" keyword supported by the openapi 3.1.0 (the actual version)

Accoding to the specification, it is an equivalent to an enum with a single value:
https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.1.3

@arthurfiorette
Copy link
Collaborator

arthurfiorette commented Sep 17, 2024

Then why we are doing this PR in the first place? I think we should use what was specified first to increase compatibility. Everything else either by a flag or just don't implement it at all.

@domoritz
Copy link
Member

Ups, I think I misunderstood the original issue. Yeah, let's keep the default behavior and if anyone needs enums, they can use the custom formatter from #1899 (comment) by @vladimir-prisada. Sorry for misleading here, everyone.

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

Successfully merging this pull request may close these issues.

Handle const like enum with only one option
3 participants