Customize OpenAPI schema
All checks were successful
ci/woodpecker/push/docker Pipeline was successful
All checks were successful
ci/woodpecker/push/docker Pipeline was successful
This commit is contained in:
parent
00dff24767
commit
5e9d90ed0b
1 changed files with 14 additions and 0 deletions
14
app/main.py
14
app/main.py
|
@ -1,5 +1,6 @@
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from fastapi.openapi.utils import get_openapi
|
||||||
from starlette.middleware.authentication import AuthenticationMiddleware
|
from starlette.middleware.authentication import AuthenticationMiddleware
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
@ -23,6 +24,18 @@ def create_ocpp_app():
|
||||||
|
|
||||||
return app_ocpp
|
return app_ocpp
|
||||||
|
|
||||||
|
def custom_openapi():
|
||||||
|
if app.openapi_schema:
|
||||||
|
return app.openapi_schema
|
||||||
|
openapi_schema = get_openapi(
|
||||||
|
title="simple-ocpp-cs",
|
||||||
|
version="0.1.0",
|
||||||
|
summary="Simple implementation of a basic OCPP 2.0.1 compliant central system (backend) for EV charging stations",
|
||||||
|
routes=app.routes,
|
||||||
|
)
|
||||||
|
app.openapi_schema = openapi_schema
|
||||||
|
return app.openapi_schema
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
responses={404: {"description": "Not found"}},
|
responses={404: {"description": "Not found"}},
|
||||||
|
@ -34,6 +47,7 @@ def create_app():
|
||||||
app.include_router(meter_value_v1.router, prefix="/v1")
|
app.include_router(meter_value_v1.router, prefix="/v1")
|
||||||
app.include_router(transaction_v1.router, prefix="/v1")
|
app.include_router(transaction_v1.router, prefix="/v1")
|
||||||
app.mount(path="/v1/ocpp", app=create_ocpp_app())
|
app.mount(path="/v1/ocpp", app=create_ocpp_app())
|
||||||
|
app.openapi = custom_openapi
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue