JsonSchema does not correspond to Serde representation
hgzimmerman opened this issue · comments
Currently, the JsonSchema
trait is derived instead of manually implemented to match the parser for IpNet
, IpV4Net
, and IpV6Net
.
This causes it to generate a schema object that indicates that for IpV4Net
, the serde deserializer expects a JSON object like:
{
"addr": "0.0.0.0",
"prefix_len": 0
}
when in reality, the deserializer expects, and serializer produces:
"0.0.0.0/0"
This can be resolved by implementing JsonSchema
manually
Hi @hgzimmerman - thanks. Yeah I figured this would be needed hence asking in the original PR #31 if the default output was actually satisfactory. Since @smklein was the original requestor for this with the use case at his employer Oxide I wonder if he could weigh in here on whether this change will work for him or not? CC @ralpha and @xfbs in case they have opinions too.
Thanks
That change works for us - the 0.0.0.0/0
format actually matches our hand-rolled implementation more closely than the derived version!
Thanks @hgzimmerman and @smklein I've merged and published these fixes.
Thanks!