juhaku / utoipa

Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Apache License 2.0
2.2k stars 170 forks source link

Support for `minItems` and `maxItems` within `request_body` #1024

Open fatihergin opened 2 weeks ago

fatihergin commented 2 weeks ago

Is this possible to define minItems and maxItems in request_body for array type parameters? I would like to define sth. like:

#[utoipa::path(
    post,
    path = "/",
    request_body(
        my_objects = Vec<MyObject>,
        description = "...",
        min_items = 0,
        max_items = 5,
    ),
)]

Thank you.

juhaku commented 2 weeks ago

Currently this is not possible. Only way to define validation rules such as min_items and max_items is to define then on named field of named field struct. This is probably something that could be evaluated in future.