-
Notifications
You must be signed in to change notification settings - Fork 9.2k
v3.3: Add a global parameters field #5446
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
Open
handrews
wants to merge
2
commits into
OAI:v3.3-dev
Choose a base branch
from
handrews:global-params
base: v3.3-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
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
15 changes: 15 additions & 0 deletions
15
tests/schema/fail/openapi-object-query-with-querystring.yaml
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,15 @@ | ||
| openapi: 3.3.0 | ||
| info: | ||
| title: API | ||
| version: 1.0.0 | ||
| parameters: | ||
| - name: myquerystring | ||
| in: querystring | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: string | ||
| - name: myquery | ||
| in: query | ||
| schema: | ||
| type: string |
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,15 @@ | ||
| openapi: 3.3.0 | ||
| info: | ||
| title: API | ||
| version: 1.0.0 | ||
| parameters: | ||
| - name: myquerystring1 | ||
| in: querystring | ||
| content: | ||
| application/json: | ||
| schema: {} | ||
| - name: myquerystring2 | ||
| in: querystring | ||
| content: | ||
| application/json: | ||
| schema: {} |
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,18 @@ | ||
| openapi: 3.3.0 | ||
| info: | ||
| title: API | ||
| version: 1.0.0 | ||
| parameters: | ||
| - name: limit | ||
| in: query | ||
| schema: | ||
| type: integer | ||
| minimum: 0 | ||
| paths: | ||
| /things: | ||
| summary: Lots of things | ||
| get: | ||
| summary: Get a list of things | ||
| responses: | ||
| default: | ||
| description: A list of things |
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.
How does this interact with definitions split across multiple files? The restriction
Makes me worried that this will not be useful outside of very narrow use cases, though if it is scoped to the file it is defined in then it might be fine (though bring it's own complexities).
Eg: I could imagine using this for authentication related headers, but often you might have a handful of authentication related routes (for login, token refresh, password reset) that don't want those headers.
The other main use case I picture is flow control/rate limit related headers which might be ok without any scoping.
By multiple files, I mean I normally structure things like
I'd wonder if being able to specify
(name, in, schema: null)or similar on a route/operation level to remove the parameter would be worthwhile.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.
Good point. Can we consider the overriding mechanism as a way to "remove" by nulling it out down stream?
Uh oh!
There was an error while loading. Please reload this page.
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.
I shudder at the idea of
schema: null. But I thinkschema: falseshould probably do just what you want.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.
@mikekistler is correct.
nullis not a valid schema butfalseis.@mnahkies We expect this to have a fairly narrow use case, and probably more for request headers or cookies than query params (or certainly path params).
Document vs API scope is a mess, currently, and there's really no way to fix it until 4.0. Things at the root level (except the Info Object) are all scoped at API level (
securityandservers), soparametersshould probably follow that rather than create yet another usage pattern (as @baywet has noted, we have too many already).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.
I'm hoping to clarify some of this a bit in 3.3. But currently I would say that global
parametersapplies in exactly the same way as globalservers,securitySchemesandtagsdo. I have my own personal interpretation of how this works today, but this may differ from others' interpretations, which is why I hope to clarify the current state and then use that to move forward with more features to allow more flexibility in how APIs are defined with multiple documents.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.
That all makes sense.
To be clear my concern on the narrow use case is that even for headers and cookies, it may often not be useable if there is no way to remove it from a few specific operations.
schema: falsewould work for me.(I can think of ways to hack around being unable to remove parameters from operations but I don't particularly like them and think it would muddy the conversation)
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.
@mnahkies While technically the spec does say that you can't remove a parameter at the Operation Object level (and therefore with this new addition, also at the Path Item Object level), setting
schema: falseeffectively does this. The UX isn't great because documentation tools will still show it, but afalseschema forbids all values so even if it is there it is not usable.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.
Overlays can remove things, can't it? so that's also an option to remove a parameter.
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.
@karenetheridge With overlays, you'd have to remove the global and distribute it to every Path Item where you wanted it, and just leave it out of those you don't.