This repository has been archived by the owner on May 25, 2023. It is now read-only.
forked from fastapi/fastapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add additonal OpenAPI metadata parameters to
FastAPI
class, shown…
… on the automatic API docs UI (fastapi#1812) Co-authored-by: Marcelo Trylesinski <[email protected]> Co-authored-by: dkreeft <[email protected]> Co-authored-by: Sebastián Ramírez <[email protected]>
- Loading branch information
1 parent
6c80e9a
commit 6f45f43
Showing
6 changed files
with
79 additions
and
19 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
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="My Super Project", | ||
description="This is a very fancy project, with auto docs for the API and everything", | ||
version="2.5.0", | ||
title="ChimichangApp", | ||
description=description, | ||
version="0.0.1", | ||
terms_of_service="http://example.com/terms/", | ||
contact={ | ||
"name": "Deadpoolio the Amazing", | ||
"url": "http://x-force.example.com/contact/", | ||
"email": "[email protected]", | ||
}, | ||
license_info={ | ||
"name": "Apache 2.0", | ||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html", | ||
}, | ||
) | ||
|
||
|
||
@app.get("/items/") | ||
async def read_items(): | ||
return [{"name": "Foo"}] | ||
return [{"name": "Katana"}] |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,31 @@ | |
openapi_schema = { | ||
"openapi": "3.0.2", | ||
"info": { | ||
"title": "My Super Project", | ||
"version": "2.5.0", | ||
"description": "This is a very fancy project, with auto docs for the API and everything", | ||
"title": "ChimichangApp", | ||
"description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n", | ||
"termsOfService": "http://example.com/terms/", | ||
"contact": { | ||
"name": "Deadpoolio the Amazing", | ||
"url": "http://x-force.example.com/contact/", | ||
"email": "[email protected]", | ||
}, | ||
"license": { | ||
"name": "Apache 2.0", | ||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html", | ||
}, | ||
"version": "0.0.1", | ||
}, | ||
"paths": { | ||
"/items/": { | ||
"get": { | ||
"summary": "Read Items", | ||
"operationId": "read_items_items__get", | ||
"responses": { | ||
"200": { | ||
"description": "Successful Response", | ||
"content": {"application/json": {"schema": {}}}, | ||
} | ||
}, | ||
"summary": "Read Items", | ||
"operationId": "read_items_items__get", | ||
} | ||
} | ||
}, | ||
|
@@ -37,4 +47,4 @@ def test_openapi_schema(): | |
def test_items(): | ||
response = client.get("/items/") | ||
assert response.status_code == 200, response.text | ||
assert response.json() == [{"name": "Foo"}] | ||
assert response.json() == [{"name": "Katana"}] |