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

Derive JsonSchema for commonly used types #1

Closed
ThouCheese opened this issue Sep 5, 2019 · 2 comments
Closed

Derive JsonSchema for commonly used types #1

ThouCheese opened this issue Sep 5, 2019 · 2 comments

Comments

@ThouCheese
Copy link

Hi! This project looks very promising for generating auto documentation for Rocket web servers. I'd like to integrate this into my application, but to do that I need a couple of derivations of JsonSchema that currently don't exists. Mainly, the chrono types for datetimes and tuple structs. Is this something that is on the roadmap, or that you might be able to help me implement myself?

@GREsau GREsau transferred this issue from GREsau/okapi Sep 7, 2019
@GREsau
Copy link
Owner

GREsau commented Sep 7, 2019

I'd like to have a general way of allowing derivations of JsonSchema for types in remote crates, which would probably be done with a #[schema(with = "TypeInMyCrate") attribute (where TypeInMyCrate implements JsonSchema), so that it can easily work with serde's remote deriving feature.

That said, for particularly popular crates like chrono, I think it's reasonable to add implementations of some types directly in schemars under a feature flag.

And JsonSchema will definitely be deriveable for tuple structs at some point, it's just not something I've gotten around to implementing yet

@GREsau
Copy link
Owner

GREsau commented Sep 8, 2019

In v0.1.8 you can now derive JsonSchema for tuple structs, and all serializable chrono types (Weekday, NaiveDate, NaiveDateTime, NaiveTime and DateTime) now have JsonSchema implementations under a feature flag.

schemars = { version = "0.1.8", features = ["chrono"] }

@GREsau GREsau closed this as completed Sep 8, 2019
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

No branches or pull requests

2 participants