GREsau / schemars

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

Incompatibility with serde_json feature "arbitrary_precision" #227

Open jayvdb opened 1 year ago

jayvdb commented 1 year ago

When I enable serde_json feature "arbitrary_precision" in my project, I get schemas that look like

type: array
minItems:
  $serde_json::private::Number: '3'
items:
  $ref: '#/components/schemas/CartesianCoordinate'

It seems like this is coming from schemars, as when I enable this feature in all my other dependencies, their tests pass, but schemars tests fail when this feature is enabled.

jayvdb commented 1 year ago

There are a lot less failures when I use https://github.com/GREsau/schemars/pull/182

GREsau commented 3 weeks ago

I threw together a proof-of-concept for a fix that should preserve arbitrary precision when a schema is de/serialized using serde_json, and falls back to serializing as a u64/i64/f64 (potentially losing precision) when serialized to other formats. But before I put a proper fix in, I'm curious what your use-case is for enabling the arbitrary_precision serde_json feature if you're not using JSON for serializing?