GREsau / schemars

Generate JSON Schema documents from Rust code
https://graham.cool/schemars/
MIT License
797 stars 223 forks source link

Preserve the order of flattened properties. #253

Closed SamirTalwar closed 1 month ago

SamirTalwar commented 10 months ago

Resolves #122.

When using #[serde(flatten)] in combination with the preserve_order feature, Schemars did not actually preserve the order; flattened properites would always be inserted last.

This change modifies the derive macro to insert flattened properties as they come.

I haven't added test cases as there don't seem to be any for preserve_order and I'm not sure how to go about doing this. However, I did add a flattened structure to the serde_attrs example, and tested it manually.

SamirTalwar commented 1 month ago

Closing this PR as this is fixed in schemars v1.0.0-alpha.3, according to https://github.com/GREsau/schemars/issues/122#issuecomment-2283588456.