You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm keen to use rust-decimal in my rust/rocket web apps which utilise the rocket-okapi, okapi and schemars to produce OpenAPI/Swagger API specifications. Supporting this basically requires adding impls: impl schemars::JsonSchema for rust_decimal::Decimal but will likely require different impls depending on the selected serde feature (eg. providing a JSON string schema with regex for the serde-str option).
I'm open to doing some work on this but thought I'd check in to see if there were any ideas on how best to implement this in a manner consistent with to existing serde support.
One challenge is that schemars doesn't support #[serde(with = <mod>)]-style macros. However, these could be supported through adding dummy "schema" structs for relevant serde features and explicitly referring to these with #[schemars(with = <struct>)] decorators.
For example:
in rust_decimal::schemars.rs:
pubstructDecimalWithAbitraryPrecision{}implJsonSchemaforDecimalWithAbitraryPrecision{
<implement JsonSchema functions specific to abitrary_precision feature>
}
Hi,
I'm keen to use rust-decimal in my rust/rocket web apps which utilise the
rocket-okapi
,okapi
andschemars
to produce OpenAPI/Swagger API specifications. Supporting this basically requires adding impls:impl schemars::JsonSchema for rust_decimal::Decimal
but will likely require different impls depending on the selectedserde
feature (eg. providing a JSON string schema with regex for theserde-str
option).I'm open to doing some work on this but thought I'd check in to see if there were any ideas on how best to implement this in a manner consistent with to existing
serde
support.One challenge is that
schemars
doesn't support#[serde(with = <mod>)]
-style macros. However, these could be supported through adding dummy "schema" structs for relevant serde features and explicitly referring to these with#[schemars(with = <struct>)]
decorators.For example:
in
rust_decimal::schemars.rs
:Then in relevant application code:
This is a bit clunky but was the best I could come up with. Any better ideas about how to implement such support?
The text was updated successfully, but these errors were encountered: