-
Notifications
You must be signed in to change notification settings - Fork 17
Fix const keyword being used in OpenAPI 3.0.3 (#241) #242
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
openapi-circe/src/test/resources/spec/3.0/const_and_enum.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "openapi": "3.0.1", | ||
| "info": { | ||
| "title": "API", | ||
| "version": "1.0.0" | ||
| }, | ||
| "components": { | ||
| "schemas": { | ||
| "const and enum" : { | ||
| "description" : "const and enum", | ||
| "enum" : [ | ||
| "const1" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this correctly rendered, since in
componentswe define both a const and an enum, and theconst_and_enum.jsonfile contains only one enum?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is that in order to get rid of the
constwe need to replace theenum. As theSchemaitself does not forbid to have aconstand anenumdefined for the same item (which of course makes not sense) we will just overwrite theenumwith the value defined inconst. Hence, what were two different things in the Schema (const and enum) will be reduced to just anenumin the JSON.Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or explained by example:
For this
schemaComponentthe following would be the JSON for OpenAPI 3.1.0 (although it does not make sense to have something being an
enumandconstat the same time):{ "openapi" : "3.1.0", "info" : { "title" : "API", "version" : "1.0.0" }, "components" : { "schemas" : { "const and enum" : { "description" : "const and enum", "enum" : [ "enum1", "enum2" ], "const" : "const1" } } } }for OpenAPI 3.0.x this will be transformed to:
{ "openapi" : "3.0.1", "info" : { "title" : "API", "version" : "1.0.0" }, "components" : { "schemas" : { "const and enum" : { "description" : "const and enum", "enum" : [ "const1" ] } } } }The above is only an edge case test. In reality it is more important to have the correct result for the
"full 3.0 schema"and"full 3.1 schema"tests.in
"/spec/3.1/schema.json"versus in
"/spec/3.0/schema.json"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok the edge case mislead me :)