-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto collect schemas recursively from usages #1065
Comments
This is an incredible addition, thanks for your hard work 👍🏻 Migrating from Poem to Axum, the single biggest issue is runtime mismatch of schema types and actual types used in practice. It's easy to return a To that end, Is the plan to incorporate full type inference -- e.g. path/params, return types, etc from usage? Or would it still be necessary after this round to manually decorate utoipa::path with Either way -- this is a great step forward, thank you. |
That's true, it has been an issue for too long, though with the 5.0.0 it will recognize the types and if something does not exist, it will fail with compile error. Moreover if you happen to rename a type, it will get renamed in
Yes, this round does not yet infer response body from return types. There has actually been a hidden feature flag This is something that most likely will be added after the 5.0.0 release. I will see further down the road when such feature will be added nonetheless. For what comes to the |
Love it, thanks @juhaku! |
Closing as done, the |
Description
Currently all schemas need to be manually listed to the
OpenApi
via#[openapi(components(schemas(...)))]
or manually by adding them directly to theOpenApi
. While this is fine, it gets burdensome for large projects and is prone to errors and in reality is not feasible in long run.Solution
Allow
utoipa
to automatically collect schemas recursively within types that implementToSchema
trait (by derive) and all usages e.g. when type implementingToSchema
is defined as a request body or response body.This does not change the fact that still handlers need to manually added to the schema either via
#[openapi(paths(...))]
or by other means.Tasks
ToSchema
trait (via derive).#[utoipa::path(request_body = ...)]
or from handler function argument for frameworks that supports request body auto recognition. These areactix_web
axum
and mayberocket
maybeIntoResponses
andToResponse
as well?utoipa-axum
(request_body and responses).Closes #1025 Closes #465
Fixes #692
Relates #662 #591 #965 #779
The text was updated successfully, but these errors were encountered: