You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
962 B
41 lines
962 B
# pip install fastapi
|
|
# pip install email-validator
|
|
# pip install pydantic
|
|
# pip install starlette
|
|
# pip install uvicorn
|
|
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.openapi.utils import get_openapi
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items():
|
|
return [{"name": "Foo"}]
|
|
|
|
|
|
def custom_openapi():
|
|
if app.openapi_schema:
|
|
return app.openapi_schema
|
|
openapi_schema = get_openapi(
|
|
title="Custom title",
|
|
version="2.5.0",
|
|
description="This is a very custom OpenAPI schema",
|
|
routes=app.routes,
|
|
)
|
|
openapi_schema["info"]["x-logo"] = {
|
|
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
|
|
}
|
|
app.openapi_schema = openapi_schema
|
|
return app.openapi_schema
|
|
|
|
|
|
app.openapi = custom_openapi
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print("see http://127.0.0.1:8000/docs")
|
|
uvicorn.run(app, #'server:app',
|
|
host='127.0.0.1', port=8000, reload=True)
|