Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonSchema does not correspond to Serde representation #40

Closed
hgzimmerman opened this issue Mar 28, 2022 · 4 comments · Fixed by #41
Closed

JsonSchema does not correspond to Serde representation #40

hgzimmerman opened this issue Mar 28, 2022 · 4 comments · Fixed by #41

Comments

@hgzimmerman
Copy link
Contributor

hgzimmerman commented Mar 28, 2022

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

@krisprice
Copy link
Owner

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

@smklein
Copy link
Contributor

smklein commented Mar 31, 2022

That change works for us - the 0.0.0.0/0 format actually matches our hand-rolled implementation more closely than the derived version!

@krisprice
Copy link
Owner

Thanks @hgzimmerman and @smklein I've merged and published these fixes.

@hgzimmerman
Copy link
Contributor Author

Thanks!

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 a pull request may close this issue.

3 participants