What's the feature you'd like to ask for.
First off, lovely framework. I would like for it to be possible to "inherit routes" when I use starlite.Controller
, in code speak this roughly translates to
A "Base Controller" that can have common routes such as
All these would return models (in my case, they would be SQLAlchemy objects)
T = TypeVar('T', bound=models.Base)
class BaseController(Controller, Generic[T]):
model = models.Base
@get('{resource_id:uuid}')
async def get_by_id(
self, resource_id: UUID, session: AsyncSession
) -> T | None:
return await session.get(self.model, resource_id)
Any inherited class can then use this like so
class Foo(BaseController[type[models.Foo]]):
path = 'foo'
tags = [path]
model = models.Foo
class Bar(BaseController[type[models.Bar]]):
path = 'Bar'
tags = [path]
model = models.Bar
Expected Behavior
I should now be able to do /foo/{resource_id}
and /bar/{resource_id}
and of course, any other routes in the base class should be added.
Additional context
ImproperlyConfiguredException
starlite.exceptions.http_exceptions.ImproperlyConfiguredException: 500: Parameter '' with type '~T' could not be mapped to an Open API type. This can occur if a user-defined generic type is resolved as a parameter. If '' should not be documented as a parameter, annotate it using the `Dependency` function, e.g., `: ... = Dependency(...)`.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too