You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem with this is that if we use Mount instead of a subclass of APIRoute in FastAPI, we lose automatic openai schema definitions for those routes. They work just fine, we can access, routing works but FastAPI won't take them into account for its openai schema creation.
FastApi will ignore Mount objects inside its routes list.
Initial solution proposal
The only solution I can think of right now, would be to make our own implementation of Mount (e.g. PestMount), so that when we define a @controller, instead of creating an APIRouter for it and then add it to the FastAPI application, we create a PestMount grouping all the routes of the controller inside it.
Then we should mess a bit with the PestApplication class, overriding the openapi method from FastAPI so that it not only takes APIRoutes into account when generating the schema, but also all routes included on the PestMount route container.
The text was updated successfully, but these errors were encountered:
Some context...
starlette
has an implementation for middlewares per group of routes onMount
:https://github.com/encode/starlette/blob/93494a46ee0f2e8b1eeafd12e466ebac15037b41/starlette/routing.py#L380-L396
The problem with this is that if we use
Mount
instead of a subclass ofAPIRoute
in FastAPI, we lose automatic openai schema definitions for those routes. They work just fine, we can access, routing works but FastAPI won't take them into account for its openai schema creation.This is why:
https://github.com/tiangolo/fastapi/blob/ac93277d3b506f4076aee1af6ae5a86406f545c6/fastapi/openapi/utils.py#L481-L484
FastApi will ignore
Mount
objects inside itsroutes
list.Initial solution proposal
The only solution I can think of right now, would be to make our own implementation of
Mount
(e.g.PestMount
), so that when we define a@controller
, instead of creating anAPIRouter
for it and then add it to the FastAPI application, we create aPestMount
grouping all the routes of the controller inside it.Then we should mess a bit with the
PestApplication
class, overriding theopenapi
method fromFastAPI
so that it not only takes APIRoutes into account when generating the schema, but also all routes included on thePestMount
route container.The text was updated successfully, but these errors were encountered: