Skip to content

Conversation

@ZackPierce
Copy link
Contributor

@ZackPierce ZackPierce commented Apr 30, 2021

Hello @mbrubeck , @reem et al, thanks for this useful library. Here's a feature enhancement that could help out.

Motivating Use Case

I would like to use types from ordered-float in one of my JSON APIs. The JSON API has a constraint that all involved types must implement JsonSchema from the schemars crate in order to wire up autogeneration of JSON schema for API documentation and discoverability.

Implementation Details

schemars is added as an optional dependency. Implementations of JsonSchema for OrderedFloat<f32|f64> and NotNan<f32|f64> are provided behind feature flag gating. Both "std" and "schemars" features are required, as the schemars crate is firmly std-only.

The provided schema match the pre-existing serde implementations which serialize the underlying float value without any additional structure.

Relevant unit tests have been added as well.

@mbrubeck mbrubeck merged commit b08dc82 into reem:master May 3, 2021
mbrubeck added a commit that referenced this pull request May 3, 2021
Release notes:

* Add optional `schemars` feature (#78).
* Re-export the `Float` trait (#79).
@mbrubeck
Copy link
Collaborator

mbrubeck commented May 3, 2021

Thanks! Version 2.2.0 has been released with this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants