Reusing the Header Parameter
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reusing the Header Parameter
I need to add the Authorization parameter to every endpoint in my document. To avoid repetition, I did create a `parameter` section in the `components` as the following and linked it at the required place:
components:
parameters:
authorization:
name: authorization
in: header
description: ''
required: true
schema:
type: string
example: '<your_api_key_token>'
But then I get a message that reads "Header parameters named Authorization are ignored..." Is there any way to solve this. Please bear in mind that the limitation I have is I need to add the Authorization information in every endpoint and I have some 100 endpoints.
- Labels:
-
Swagger Editor
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried securing your endpoints using one of the security requirement objects?
https://swagger.io/specification/#security-requirement-object
It seems that the issue is the fact that the header parameter is named authorization. Could you try naming the parameter something else?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@nrrayengar The "Authorization" header must be defined as a security scheme rather than a parameter. In your example, you need to define it as an API key. Check out the examples in:
https://swagger.io/docs/specification/authentication/api-keys/
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
