Reputation: 2766
Currently, I am using this type of docstring with Flassger which works fine:
"""End Point to create something
---
parameters:
- name: body
in: body
type: string
required: true
- name: token
in: header
description: an authorization header
required: true
type: string
responses:
200:
description: Some description
"""
And I am able to send the request from ui like this:
But I need to make the token parameter global on this page, so that the user only need to fill this just once. What do I need to do to achieve that?
Upvotes: 1
Views: 817
Reputation: 309
All you need to do is define the authorization token in the api definitions. Try something like this:
securityDefinitions:
Token:
type: apiKey
name: Token
in: header
And then put this code in the endpoint you want to secure with the token:
security:
-Token: []
In your example:
parameters:
- name: body
in: body
type: string
required: true
security
- Token:[]
responses:
200:
description: Some description
If you want to secure all the endpoints with the token do like this:
securityDefinitions:
Token:
type: apiKey
name: Token
in: header
security
- Token:[]
Upvotes: 1