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

Support min_items, etc. for non-array, single-type collections #917

Open
Shadow53 opened this issue Nov 26, 2024 · 1 comment
Open

Support min_items, etc. for non-array, single-type collections #917

Shadow53 opened this issue Nov 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Shadow53
Copy link

Description of the feature

I'd like to be able to use min_items with HashSet<T>, but it is not currently supported. The error looks like:

Diagnostics:
the trait bound `std::collections::HashSet<MyType>: std::ops::Deref` is not satisfied
the trait `poem_openapi::Validator<T>` is implemented for `poem_openapi::validation::MinItems`
required for `poem_openapi::validation::MinItems` to implement `poem_openapi::Validator<std::collections::HashSet<MyType>>` [E0277]

I figure it makes sense for the feature request to also encompass BTreeSet and maybe tuples of a single type.

Code example (if possible)

#[derive(poem_openapi::Object)]
struct MyObject {
    #[oai(validator(min_items = 1))]
    my_set: HashSet<String>,
}

I'm willing to provide a PR if this feature would be accepted.

@Shadow53 Shadow53 added the enhancement New feature or request label Nov 26, 2024
@attila-lin
Copy link
Collaborator

Yes please. PR are welcome~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants