Skip to content
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

Add auto collect schemas for utoipa-axum #1072

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Oct 2, 2024

Add support for auto collecting schemas from handlers annotated with #[utoipa::path(...)] macro used with utoipa-axum routes! macro.

Update examples and docs.

From now on the there is no need to merge schemas from separate OpenApi since the schemas will get collected from the handlers.

 #[derive(utoipa::ToSchema)]
 struct User {
     id: i32,
 }

 #[utoipa::path(get, path = "/user", responses((status = OK, body = User)))]
 async fn get_user() -> Json<User> {
     Json(User { id: 1 })
 }

 let (router, api) = OpenApiRouter::new()
     .routes(routes!(get_user))
     .split_for_parts();

Closes #1065

Add support for auto collecting schemas from handlers annotated with
`#[utoipa::path(...)]` macro used with `utoipa-axum` `routes!` macro.

Update examples and docs.

From now on the there is no need to merge schemas from separate
OpenApi since the schemas will get collected from the handlers.
```rust
 #[derive(utoipa::ToSchema)]
 struct User {
     id: i32,
 }

 #[utoipa::path(get, path = "/user", responses((status = OK, body = User)))]
 async fn get_user() -> Json<User> {
     Json(User { id: 1 })
 }

 let (router, api) = OpenApiRouter::new()
     .routes(routes!(get_user))
     .split_for_parts();
```
@juhaku juhaku merged commit 8a5bb72 into master Oct 2, 2024
22 checks passed
@juhaku juhaku deleted the feature-axum-auto-collect-schemas branch October 2, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

Auto collect schemas recursively from usages
1 participant