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

Auto collect tuple responses schema references #1071

Merged
merged 1 commit into from
Oct 1, 2024

Commits on Oct 1, 2024

  1. Auto collect tuple responses schema references

    Refactor Tuple responses parsing unifying it with request body parsing.
    This allows reusing same components when serialized to tokens
    making it less error prone and removing duplication.
    
    This also removes the `content_type = [...]` array format from
    `ToResponse` and `IntoResponses` derive types as well as from tuple
    style responses. Same as with request bodies the multiple content
    types need to defined with `content(...)` attribute.
    
    Implement auto collect response schema references from tuple style
    responses within `#[utoipa::path(...)]` attribute macro. Schema
    references will be collected recursively in same manner as for request
    bodies.
    
    Example of supported syntax. The `User` will be automatically collected
    to OpenApi when `get_user` path is registered to the `OpenApi`.
    ```rust
     #[derive(utoipa::ToSchema)]
     struct User {
         name: String,
     }
    
     #[utoipa::path(
         get,
         path = "/user",
         responses(
             (status = 200, body = User)
         )
     )]
     fn get_user() {}
    ```
    juhaku committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    9a6f6be View commit details
    Browse the repository at this point in the history