Skip to content

Commit

Permalink
Release 0.6.2 (#169)
Browse files Browse the repository at this point in the history
* release 0.6.2
  • Loading branch information
kemingy authored Sep 22, 2021
1 parent 182cf5d commit f60a4d0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
70 changes: 70 additions & 0 deletions examples/security_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from flask import Flask
from pydantic import BaseModel

from spectree import SecurityScheme, SpecTree


class Req(BaseModel):
name: str


security_schemes = [
SecurityScheme(
name="PartnerID",
data={"type": "apiKey", "name": "partner-id", "in": "header"},
),
SecurityScheme(
name="PartnerToken",
data={"type": "apiKey", "name": "partner-access-token", "in": "header"},
),
SecurityScheme(
name="test_secure",
data={
"type": "http",
"scheme": "bearer",
},
),
SecurityScheme(
name="auth_oauth2",
data={
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/oauth/authorize",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"read": "Grants read access",
"write": "Grants write access",
"admin": "Grants access to admin operations",
},
},
},
},
),
]

app = Flask(__name__)
api = SpecTree(
"flask",
security_schemes=security_schemes,
SECURITY={"test_secure": []},
)


@app.route("/ping", methods=["POST"])
@api.validate(
json=Req,
security=[{"PartnerID": [], "PartnerToken": []}, {"auth_oauth2": ["read"]}],
)
def ping():
return "pong"


@app.route("/")
def index():
return "hello"


if __name__ == "__main__":
api.register(app)
app.run(port=8000)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="spectree",
version="0.6.1",
version="0.6.2",
author="Keming Yang",
author_email="[email protected]",
description=(
Expand Down

0 comments on commit f60a4d0

Please sign in to comment.