-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Sending additional headers #3605
Comments
Is this repetitive way the only way to handle this?
|
We do have a request interceptor option1... but that's for programmatic modification of outgoing requests, not defining custom data at request runtime via the UI. I'm not quite sure what you're trying to achieve here, though. Having What are you trying to handle by defining custom headers? If you share some more information, we may be able to point you in the right direction. |
I updated the snippet above as it was just meant to clarify that I have multiple custom headers that are required to be send which each and every request. I have like 40 paths defined and everytime I have to add the 3x What I want to know is if there is a way to specify that these headers need to be send with every request and how to display inputs for these headers somewhere on the top of the page. Is it even possible to have global parameters for every request that render inputs somewhere on the page like they do for path parameters? |
@faustbrian, what kind of headers are these? If they are API keys, you can describe them using the If they are generic headers like paths:
/something:
# Path-level parameters, inherited by all operations with that path
parameters:
- $ref: '#/parameters/customHeader1'
- $ref: '#/parameters/customHeader2'
- $ref: '#/parameters/customHeader3'
get:
...
post:
...
patch:
... There are existing feature requests for global parameter and parameter groups in the OpenAPI Specification repository: |
Yeah I know about the securityDefinitions and security keywords but they are generic headers that are required by the server to know about a few things which is why I am currently doing the Guess I will keep doing that till OpenAPI has support for global or grouped parameters to clean things up, just seems overly repetitive. Thanks! |
@faustbrian, there is a workaround using YAML anchors, as shown here. Instead of repeating all the # &-anchors must be defined BEFORE they are *-referenced!
x-globalParameters: &GLOB_PARAMS
- $ref: '#/parameters/customHeader1'
- $ref: '#/parameters/customHeader2'
- $ref: '#/parameters/customHeader3'
paths:
/something:
parameters: *GLOB_PARAMS
get:
parameters:
- in: query
type: string
name: q
description: ''
required: true
...
post:
...
/another_path:
parameters: *GLOB_PARAMS
get:
...
post:
... |
Thanks, I will give it a shot. |
I am currently using Swagger UI 3.1.6 and can't figure out how to set additional headers that will be send on every request.
Is there some way I can set additional headers in the swagger.json or even add inputs to the UI where the developer can set the value of those custom headers directly through Swagger UI configuration?
The text was updated successfully, but these errors were encountered: