Closed RaulTrombin closed 4 months ago
Tryed a mix of: https://github.com/paperclip-rs/paperclip/blob/555a460cdfbc295edb504c3d7f441253a5c681ae/core/src/v2/models.rs#L519 and https://paperclip-rs.github.io/paperclip/actix-security.html
#[derive(Apiv2Schema, Debug, Deserialize, Serialize)]
#[openapi(minimum=0, maximum=255)]
pub struct ApiNeopixel {
#[openapi(minimum=0, maximum=255)]
red: u8,
green: u8,
blue: u8,
}
no success yet:
Maybe we can integrate with validator:
#[derive(Apiv2Schema, Debug, Deserialize, Serialize, Validate)]
pub struct ApiNeopixel {
#[validate(range(min = 0, max = 255))]
red: u8,
#[validate(range(min = 0, max = 255))]
green: u8,
#[validate(range(min = 0, max = 255))]
blue: u8,
}
Yeah a validator like that seems like a good idea. Although in general we could also improve things, as with u8 the min and max should also be set?
Yeah a validator like that seems like a good idea. Although in general we could also improve things, as with u8 the min and max should also be set?
I think it could be an optional field, if not set - It will take the minumum and maximum values from integer type. But if defined you can set your own limits.
Sorry about the long delay in addressing this.. With this I think the min/max are addressed for both your issues, please let me know otherwise.
There is some way/instruction on how to set ranged inputs? something at the struct field like: [api_v2(min_value = 0)]
For enuns and direct type values it works pretty fine.