Open javihc opened 7 months ago
Hey. In my project, I've implemented the ToSchema
trait manually. I added a constraint for T:
impl<'a, T: ToSchema<'a>> ToSchema<'a> for OneOrMany<T> {
fn schema() -> (
&'a str,
utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>,
) {
let (schema_name, schema) = T::schema();
let object = /* your schema */;
("OneOrMany", RefOr::<Schema>::T(Schema::Object(object)))
}
}
I am writting an API with Axum and I am using and enum to recevibe o single value or a list of values. For that I am using a Enum with a generic type
T
To generate the OpenAPi I use aliases
aliases(StringOneOrMany = OneOrMany<String>)
and when I generate the openapi.json it serialize asHow can I generate the schema correctly without using
value_type=
With
schemars
the is no problem.