-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
bug: openapi schema generation for DTO with generic wrapper #2929
Comments
peterschutt
changed the title
Issue from Discord
big: openapi schema generation for DTO with generic wrapper
Dec 24, 2023
peterschutt
changed the title
big: openapi schema generation for DTO with generic wrapper
bug: openapi schema generation for DTO with generic wrapper
Dec 24, 2023
peterschutt
added a commit
that referenced
this issue
Dec 24, 2023
This PR proposes a method to repair schema generation when a DTO supported type is wrapped with a generic wrapper. Prior to this PR, the generic wrapper type was omitted from the generated OpenAPI schema for the type. WIP. Closes #2929
provinzkraut
pushed a commit
that referenced
this issue
Feb 3, 2024
This PR proposes a method to repair schema generation when a DTO supported type is wrapped with a generic wrapper. Prior to this PR, the generic wrapper type was omitted from the generated OpenAPI schema for the type. WIP. Closes #2929
4 tasks
peterschutt
added a commit
that referenced
this issue
Apr 11, 2024
* fix: Fix schema for generic wrapped return types with DTO Adds failing test. Closes #2929 * fix: remove redundant type var * fix: fix openapi schema for generic return types with dto Prior behavior of using the `backend.annotation` as the basis for generating the openapi schema for the represented type is not applicable for the case where the DTO supported type is wrapped in a generic outer object. This PR detects the case where we unwrap an outer generic type, and rebuilds the generic annotation in a manner appropriate for schema generation, before generating the schema for the annotation. It does this by substituting the DTOs transfer model for the original model in the original annotations type arguments. This is really treating a symptom of the generic outer type being removed from the annotation before the DTO backend receives it, which is a design flaw that adds quite a bit of complexity. The DTOs should treat annotations at a whole, rebuild the complete annotation substituting out any supported types found within with transfer models. Also, we don't really have a need for a separate backend anymore, now that we are only supporting one serialization library (backend were introduced when we were trying to support either pydantic or msgspec (and attrs?) throughout the whole application. * test: add another test.
This issue has been closed in #3371. The change will be included in the upcoming patch release. |
peterschutt
added a commit
that referenced
this issue
Apr 11, 2024
* fix: Fix schema for generic wrapped return types with DTO Adds failing test. Closes #2929 * fix: remove redundant type var * fix: fix openapi schema for generic return types with dto Prior behavior of using the `backend.annotation` as the basis for generating the openapi schema for the represented type is not applicable for the case where the DTO supported type is wrapped in a generic outer object. This PR detects the case where we unwrap an outer generic type, and rebuilds the generic annotation in a manner appropriate for schema generation, before generating the schema for the annotation. It does this by substituting the DTOs transfer model for the original model in the original annotations type arguments. This is really treating a symptom of the generic outer type being removed from the annotation before the DTO backend receives it, which is a design flaw that adds quite a bit of complexity. The DTOs should treat annotations at a whole, rebuild the complete annotation substituting out any supported types found within with transfer models. Also, we don't really have a need for a separate backend anymore, now that we are only supporting one serialization library (backend were introduced when we were trying to support either pydantic or msgspec (and attrs?) throughout the whole application. * test: add another test. (cherry picked from commit 40a5685)
peterschutt
added a commit
that referenced
this issue
Apr 11, 2024
* fix: Fix schema for generic wrapped return types with DTO Adds failing test. Closes #2929 * fix: remove redundant type var * fix: fix openapi schema for generic return types with dto Prior behavior of using the `backend.annotation` as the basis for generating the openapi schema for the represented type is not applicable for the case where the DTO supported type is wrapped in a generic outer object. This PR detects the case where we unwrap an outer generic type, and rebuilds the generic annotation in a manner appropriate for schema generation, before generating the schema for the annotation. It does this by substituting the DTOs transfer model for the original model in the original annotations type arguments. This is really treating a symptom of the generic outer type being removed from the annotation before the DTO backend receives it, which is a design flaw that adds quite a bit of complexity. The DTOs should treat annotations at a whole, rebuild the complete annotation substituting out any supported types found within with transfer models. Also, we don't really have a need for a separate backend anymore, now that we are only supporting one serialization library (backend were introduced when we were trying to support either pydantic or msgspec (and attrs?) throughout the whole application. * test: add another test. (cherry picked from commit 40a5685)
peterschutt
added a commit
that referenced
this issue
May 1, 2024
* fix: Fix schema for generic wrapped return types with DTO Adds failing test. Closes #2929 * fix: remove redundant type var * fix: fix openapi schema for generic return types with dto Prior behavior of using the `backend.annotation` as the basis for generating the openapi schema for the represented type is not applicable for the case where the DTO supported type is wrapped in a generic outer object. This PR detects the case where we unwrap an outer generic type, and rebuilds the generic annotation in a manner appropriate for schema generation, before generating the schema for the annotation. It does this by substituting the DTOs transfer model for the original model in the original annotations type arguments. This is really treating a symptom of the generic outer type being removed from the annotation before the DTO backend receives it, which is a design flaw that adds quite a bit of complexity. The DTOs should treat annotations at a whole, rebuild the complete annotation substituting out any supported types found within with transfer models. Also, we don't really have a need for a separate backend anymore, now that we are only supporting one serialization library (backend were introduced when we were trying to support either pydantic or msgspec (and attrs?) throughout the whole application. * test: add another test. (cherry picked from commit 40a5685)
peterschutt
added a commit
that referenced
this issue
May 2, 2024
* fix: Fix schema for generic wrapped return types with DTO Adds failing test. Closes #2929 * fix: remove redundant type var * fix: fix openapi schema for generic return types with dto Prior behavior of using the `backend.annotation` as the basis for generating the openapi schema for the represented type is not applicable for the case where the DTO supported type is wrapped in a generic outer object. This PR detects the case where we unwrap an outer generic type, and rebuilds the generic annotation in a manner appropriate for schema generation, before generating the schema for the annotation. It does this by substituting the DTOs transfer model for the original model in the original annotations type arguments. This is really treating a symptom of the generic outer type being removed from the annotation before the DTO backend receives it, which is a design flaw that adds quite a bit of complexity. The DTOs should treat annotations at a whole, rebuild the complete annotation substituting out any supported types found within with transfer models. Also, we don't really have a need for a separate backend anymore, now that we are only supporting one serialization library (backend were introduced when we were trying to support either pydantic or msgspec (and attrs?) throughout the whole application. * test: add another test. (cherry picked from commit 40a5685)
A fix for this issue has been released in v2.9.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
None yet
0 participants
Handler such as:
Renders such as (only generates schema for the model type, not the wrapper type):
Issue is that we don't pass the full annotation from the DTO to the backend, we only pass the model type that is extracted from the annotation and the name of the attribute that it exists upon on the wrapper class. So, when the DTO is called upon to generate the openapi schema for the type, it doesn't incorporate the wrapper type, only the model.
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: