Ask a Question

How to add examples/API key values in swagger document

shivasai
New Contributor

How to add examples/API key values in swagger document

I want to add the header key as X-API-KEY and I want to add the value of that header, so as of now in the document I have seen how to add the key of the header but I have no idea how to add the value of the header, can anyone give me the solution for this?

 

components:

securitySchemes:
ApiKeyAuth: # arbitrary name for the security scheme
type: apiKey
in: header # can be "header", "query" or "cookie"
name: X-API-KEY # name of the header, query parameter or cookie

3 REPLIES 3
chichepo
Champion Level 3

Hi @shivasai 

Do you mean this:

chichepo_0-1685965387985.png

 

shivasai
New Contributor

shivasai_0-1685965710640.png
Hi @chichepo ,
X-API-Key: abcdef12345

As you see in the above picture we are using `apikey`
There I am able to see the name:X-API-KEY as the key of the header, If I want to add the value of the header like value:abcdef12345 in swagger documentation, How can I add that?

chichepo
Champion Level 3

@shivasai 
Pardon me, I missed the fact that you were in securityScheme.

I am not sure you can.

You are going to expose a kind of "sensitive" data.
In another hand, you may try to define a "Template" for the field (i.e.: APIKEY) to document the expected field content.

Let us know if you find something

cancel
Showing results for 
Search instead for 
Did you mean: