juhaku / utoipa

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

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

Open fatihergin opened 2 months ago

fatihergin commented 2 months 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 months 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.