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

Support for #[derive(Serialize)] #72

Closed
LouisGariepy opened this issue May 26, 2022 Discussed in #71 · 2 comments · Fixed by #86
Closed

Support for #[derive(Serialize)] #72

LouisGariepy opened this issue May 26, 2022 Discussed in #71 · 2 comments · Fixed by #86
Milestone

Comments

@LouisGariepy
Copy link
Member

Discussed in #71

Originally posted by ianpurton May 26, 2022
Would you consider adding the ability to tag the structs you create with #[derive(Serialize)]?

The reason for this is that in a lot of web frameworks you can convert structs to JSON as long as they are tagged with the Serde macro.

For example see how Axum handles it.

https://docs.rs/axum/latest/axum/struct.Json.html

perhaps an argument --derive '#[derive(serve::Serialize)]' or perhaps --struct-prefix

Thanks

@LouisGariepy
Copy link
Member Author

LouisGariepy commented May 26, 2022

For complex serialization processes involving serde(...) attributes, I'd rather have users utilize a type mapping, but for simple cases, deriving Serialize reduces unnecessary boilerplate significantly.

I believe all Cornucopia-supported types either do or could derive Serialize. Maybe we can add a --serialize flag for the CLI (and something similar for the API).

@LouisGariepy LouisGariepy added this to the v0.8 milestone May 26, 2022
@LouisGariepy
Copy link
Member Author

In the works...!

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.

1 participant