Using add_pagination breaks the custom OpenAPI configuration.
mmzeynalli opened this issue · 4 comments
mmzeynalli commented
So, in my project, I have a custom openAPI config:
def custom_openapi(app: Any) -> Any | Dict[str, Any]:
"""OpenApi settings"""
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
title=settings.APP_TITLE,
version=settings.API_VERSION,
description=settings.APP_DESCRIPTION,
routes=app.routes,
)
openapi_schema['components']['securitySchemes'] = {
'Bearer Auth': {
'type': 'http',
'scheme': 'bearer',
'in': 'header',
'bearerFormat': 'JWT',
'name': 'Authorization',
'description': "Enter: **'<JWT>'**, where JWT is the access token",
},
}
app.openapi_schema = openapi_schema
return app.openapi_schema
Which worked all well until I added the add_pagination(app)
line to the code. It does not matter if this function is before or after the custom_openapi call.
uriyyo commented
Hi @mmzeynalli,
Could you please put your openapi schema patch inside lifespan?
@asynccontextmanager
async def lifespan(app: FastAPI):
custom_openapi(app)
yield
app = FastAPI(lifespan=lifespan)
mmzeynalli commented
It works, but I would ask for a fix, as this is a workaround. Thanks though.
uriyyo commented
Hi @mmzeynalli,
New version 0.12.22
has been released, this issue should be fixed.
uriyyo commented
Hi @mmzeynalli,
I'm closing this issue, please reopen it in case if issue still appears on your side.