-
Notifications
You must be signed in to change notification settings - Fork 197
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
Generate ToSchema
generic bounds on impl instead of requiring it on definition
#1079
Conversation
- Each generic types now automatically get a `ToSchema` bound in where clause of generated `impl` blocks. Thus the user does not need to explicitly add `ToSchema` bounds on struct definitions. - Attribute `schema(bound = ..)` is introduced for struct or enum containers to opt-out the automatic `ToSchema` bounds addition, by manually provide where clause bounds for the generated impl blocks. The attribute is inspired by `serde(bound = ..)`. Eg. `schema(bound = "")` can be used to remove bounds in case of `PhantomData` types.
09e5d11
to
71ae28b
Compare
@juhaku Seems you are introducing some merge conflicts 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good: 🎉 Thanks for the patch.
I updated it a bit, mainly I fixed the tests and rebased it above the master.
However could you update the docs for the new functionality in /utoipa-gen/src/lib.rs
for what is changed in ToSchema
derive macro. Also add entry to the utoipa-gen/CHANGELOG.md
to top most of suitable category of unreleased changes. Maybe under Added
title.
71ae28b
to
ca30255
Compare
Yeah, that was unfortunate, but fixed them. |
706b694
to
020769e
Compare
Updated docs and added CHANGELOG. Seems the doctest for utoipa-gen ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, 🙇 🥇
Right, yeah there might still be some of those, I'll fix them later on. |
Fixes #1078
Each generic types now automatically get a
ToSchema
bound in where clause of generatedimpl
blocks. Thus the user does not need to explicitly addToSchema
bounds on struct definitions.Attribute
schema(bound = ..)
is introduced for struct or enum containers to opt-out the automaticToSchema
bounds addition, by manually provide where clause bounds for the generated impl blocks. The attribute is inspired byserde(bound = ..)
.Eg.
schema(bound = "")
can be used to remove bounds in case ofPhantomData
types.This PR is based on 61c98bb instead of
master
becausemaster
is already failing the test after the rc version bump (snapshot assertion failure inopenapi_schemas_resolve_schema_references
and friends). It does not conflict anyway.