Ask a Question

Reusing the Header Parameter

nrrayengar
Frequent Visitor

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. 

 

2 REPLIES 2
abonstrom
Staff

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?

 
HKosova
SmartBear Alumni (Retired)

@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. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: