Created
August 2, 2022 13:45
-
-
Save deangrant/81c474d6eb991f0904db4793330d6d6d to your computer and use it in GitHub Desktop.
Example YAML block for configuring Swagger 2.0 with Bearer security definition for authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: 2.0 | |
securityDefinitions: | |
Bearer: | |
type: apiKey | |
in: header | |
name: Authorization | |
paths: | |
/auth: | |
post: | |
summary: Get a bearer token | |
tags: | |
- Authorization | |
description: > | |
Generates a bearer token for authorization | |
parameters: | |
- in: body | |
name: body | |
required: true | |
description: | |
schema: | |
$ref: "#definitions/RequestAuth" | |
/example: | |
get: | |
security: | |
- Bearer: [] | |
defintions: | |
RequestAuth: | |
type: object | |
properties: | |
username: | |
type: string | |
description: > | |
The username to pass to the application credential requirements. | |
example: ecantona@manutd.com | |
password: | |
type: string | |
description: > | |
The username to pass to the application credential requirements. | |
example: W3M61!PF8svRjYzi | |
ResponseAuth: | |
type: object | |
properties: | |
token: | |
type: string | |
description: > | |
Encoded string containing the bearer token for authorization. | |
example: > | |
eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJLanhjZENPbXVzcV9GNTR5dFZpLVJQbWZNR3RLO | |
WNVYkJqRk5wNDZucy1VIn0.eyJleHAiOjE2NTk0NDMzODQsImlhdCI6MTY1OTQ0MzA4NCwianRpIjoiNGI2OTdjYT | |
AtZWFlYS00OGM4LWI0NTUtODk4YmEzNzAzMTZlIiwiaXNzIjoiaHR0cDovL2lkZW50aXR5OjgwODAvcmVhbG1zL0d | |
lb2dlbnRpYSIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiIxNmY4ODIwNy02YmMwLTQ3YjUtOWU1My1kOWI4OTRmZDdj | |
ZWMiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhcGkiLCJzZXNzaW9uX3N0YXRlIjoiM2ZlMDNjNDktYjQ3Ny00NzBjL | |
Tk0YzktZmEzMmVkZWU1ODNmIiwiYWNyIjoiMSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2 | |
VzcyIsImRlZmF1bHQtcm9sZXMtZ2VvZ2VudGlhIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2V | |
zcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2 | |
aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6ImVtYWlsIHByb2ZpbGUiLCJzaWQiOiIzZmUwM2M0OS1iNDc3LTQ3MGMtO | |
TRjOS1mYTMyZWRlZTU4M2YiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmFtZSI6IkNobG9lIExldnkiLCJwcmVmZX | |
JyZWRfdXNlcm5hbWUiOiJjbGV2eUBjb21wYW55LmNvbSIsImdpdmVuX25hbWUiOiJDaGxvZSIsImZhbWlseV9uYW1 | |
lIjoiTGV2eSIsImVtYWlsIjoiY2xldnlAY29tcGFueS5jb20ifQ.ohfWmEtFDjLbSquQCse0hZ4z_9oxenKZv3clG | |
SFEsbGYNCae60ow_YYqUxPzRBPNZRchzkSJQ8J39ZGHrBS_N8V_907ixQH3tipz3plAbXu9MblM4rxhP1Ed9X3brT | |
7MM-CWEIR3ztkvRt83GjP8mjY7CJiB8ip9aLz0t_qYf7GaYTwLH0G5EdrxndhO_0_sVcY5DamSzz16DJxEpU_MMQy | |
NqYdz8iP2uUebwVEzlgvtqD7djLsGelViOz3zIWNNFp_gb7be1tqPCe8vy0MOGqPswlX-YbgOE-ZcZg_2rPN4WnAN | |
PL4s4KR8i644NXFM885IBY5cobnV3FP2Y71ZfA | |
ResponseDefaultError: | |
type: object | |
properties: | |
error: | |
type: object | |
properties: | |
code: | |
description: HTTP status code for the response | |
type: integer | |
message: | |
description: Error message | |
type: string | |
status: | |
description: Error status | |
type: string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment