Skip to content

Commit

Permalink
Add example of using a security_scheme to the documentation (#589)
Browse files Browse the repository at this point in the history
* Add example of using a security_scheme to the documentation

* Update AUTHORS and add new security scheme doc example to README as well

* Forgot to add all of the bits to the JSON output
  • Loading branch information
teancom committed Aug 18, 2020
1 parent 3737885 commit f075149
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -63,3 +63,4 @@ Contributors (chronological)
- Ashutosh Chaudhary `@codeasashu <https://github.com/codeasashu>`_
- Fedor Fominykh `@fedorfo <https://github.com/fedorfo>`_
- Colin Bounouar `@Colin-b <https://github.com/Colin-b>`_
- David Bishop `@teancom <https://github.com/teancom>`_
26 changes: 26 additions & 0 deletions README.rst
Expand Up @@ -67,6 +67,11 @@ Example Application
name = fields.Str()
# Optional security scheme support
api_key_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"}
spec.components.security_scheme("ApiKeyAuth", api_key_scheme)
# Optional Flask support
app = Flask(__name__)
Expand All @@ -77,6 +82,8 @@ Example Application
---
get:
description: Get a random pet
security:
- ApiKeyAuth: []
responses:
200:
content:
Expand Down Expand Up @@ -105,6 +112,11 @@ Generated OpenAPI Spec
# "/random": {
# "get": {
# "description": "Get a random pet",
# "security": [
# {
# "ApiKeyAuth": []
# }
# ],
# "responses": {
# "200": {
# "content": {
Expand Down Expand Up @@ -158,6 +170,13 @@ Generated OpenAPI Spec
# }
# }
# }
# "securitySchemes": {
# "ApiKeyAuth": {
# "type": "apiKey",
# "in": "header",
# "name": "X-API-Key"
# }
# }
# }
# }
# }
Expand All @@ -180,6 +199,11 @@ Generated OpenAPI Spec
# type: array
# name: {type: string}
# type: object
# securitySchemes:
# ApiKeyAuth:
# in: header
# name: X-API-KEY
# type: apiKey
# info: {title: Swagger Petstore, version: 1.0.0}
# openapi: 3.0.2
# paths:
Expand All @@ -191,6 +215,8 @@ Generated OpenAPI Spec
# content:
# application/json:
# schema: {$ref: '#/components/schemas/Pet'}
# security:
# - ApiKeyAuth: []
# tags: []
Expand Down
28 changes: 27 additions & 1 deletion docs/index.rst
Expand Up @@ -47,6 +47,11 @@ Example Application
name = fields.Str()
# Optional security scheme support
api_key_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"}
spec.components.security_scheme("ApiKeyAuth", api_key_scheme)
# Optional Flask support
app = Flask(__name__)
Expand All @@ -57,6 +62,8 @@ Example Application
---
get:
description: Get a random pet
security:
- ApiKeyAuth: []
responses:
200:
description: Return a pet
Expand Down Expand Up @@ -121,13 +128,25 @@ Generated OpenAPI Spec
# "type": "string"
# }
# }
# }
# },
# }
# },
# "securitySchemes": {
# "ApiKeyAuth": {
# "type": "apiKey",
# "in": "header",
# "name": "X-API-Key"
# }
# },
# "paths": {
# "/random": {
# "get": {
# "description": "Get a random pet",
# "security": [
# {
# "ApiKeyAuth": []
# }
# ],
# "responses": {
# "200": {
# "description": "Return a pet",
Expand Down Expand Up @@ -171,6 +190,11 @@ Generated OpenAPI Spec
# name:
# type: string
# type: object
# securitySchemes:
# ApiKeyAuth:
# in: header
# name: X-API-KEY
# type: apiKey
# paths:
# /random:
# get:
Expand All @@ -182,6 +206,8 @@ Generated OpenAPI Spec
# schema:
# $ref: '#/components/schemas/Pet'
# description: Return a pet
# security:
# - ApiKeyAuth: []
User Guide
==========
Expand Down

0 comments on commit f075149

Please sign in to comment.