jonasbb / serde_with

This crate provides custom de/serialization helpers to use in combination with serde's `with`-annotation and with the improved `serde_as`-annotation.
https://docs.rs/serde_with
Apache License 2.0
667 stars 72 forks source link

`schemars_0_8` feature fails to compile when `schemars/preserve_order` is active #762

Closed campbellcole closed 4 months ago

campbellcole commented 4 months ago

When schemars/preserve_order is enabled, the Map type alias used in e.g. ObjectValidation::properties switches from BTreeMap to IndexMap, and IndexMap::append does not exist, causing this line to fail compilation: https://github.com/jonasbb/serde_with/blob/2274dd142afbd6788ad43cba7f66710af78c4e03/serde_with/src/schemars_0_8.rs#L573

This feature is enabled by default by rocket_okapi which is how I encountered this: https://github.com/GREsau/okapi/blob/cd59fb61c5c8db1ce1976cb782efd544d8f99c38/rocket-okapi/Cargo.toml#L33-L36

I don't know off the top of my head what method IndexMap has that is equivalent to BTreeMap::append but I'd imagine this feature can be checked or a notice in the documentation could point out this incompatibility.

Thanks

jonasbb commented 4 months ago

Thanks for reporting that. It is a bit unfortunate that the API differs here. I have a fix in #764 and tested it manually.