-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadataForAPI.py
More file actions
79 lines (59 loc) · 1.72 KB
/
metadataForAPI.py
File metadata and controls
79 lines (59 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from fastapi import FastAPI
description = """
ChimichangApp API helps you do awesome stuff. 🚀
## Items
You can **read items**.
## Users
You will be able to:
* **Create users** (_not implemented_).
* **Read users** (_not implemented_).
"""
app = FastAPI(
title="ChimichangApp",
description=description,
summary="Deadpool's favorite app. Nuff said.",
version="0.0.1",
terms_of_service="http://example.com/terms/",
contact={
"name": "Deadpoolio the Amazing",
"url": "http://x-force.example.com/contact/",
"email": "dp@x-force.example.com",
},
license_info={
"name": "Apache 2.0",
# "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
"identifier": "MIT",
},
)
tags_metadata = [
{
"name": "users",
"description": "Operations with users. The **login** logic is also here.",
},
{
"name": "items",
"description": "Manage items. So _fancy_ they have their own docs.",
"externalDocs": {
"description": "Items external docs",
"url": "https://fastapi.tiangolo.com/",
},
},
]
app1 = FastAPI(openapi_tags=tags_metadata)
@app1.get("/users/", tags=["users"])
async def get_users():
return [{"name": "Harry"}, {"name": "Ron"}]
@app1.get("/items/", tags=["items"])
async def get_items():
return [{"name": "wand"}, {"name": "flying broom"}]
@app1.get("/items/")
async def read_items():
return [{"name": "Katana"}]
app2 = FastAPI(openapi_url="/api/v1/openapi.json")
@app2.get("/items/")
async def read_items():
return [{"name": "Foo"}]
app3 = FastAPI(docs_url="/documentation", redoc_url=None)
@app3.get("/items/")
async def read_items():
return [{"name": "Foo"}]