This PR adds support for real generics which allows users to use deeply nested generic types as schemas without the alias hassle known to users. This commit will remove the old aliases support and implement completely new generics handling. (Something that many has been longing for long)
This commit further enhances the implementation for full generic support. From now on the full type paths need used to declare the types in the OpenApi and #[utoipa::path] macros.
As further elaborated here https://github.com/juhaku/utoipa/pull/1020#issue-2503474650 the name of the schema is now resolved form the type name and possible generic arguments or via as = ... attribute and possible generic arguments. This name is then used across the OpenApi. This makes it a single place to define the name or prefixed name for the type unlike
previously the path of the schema in OpenApi macro or request_body or response body was added to the name.
This PR will also change the schema!(...) macro functionality to correctly generate schemas for arbitrary types even generic ones. Prior to this commit the generics where not resolved correctly. Still all generic arguments must implement ToSchema trait in order to generate schema in first place.
Clean up the code and enhance documentation.
Breaking changes
Removed old aliases support
Schemas now need to be defined with full type path as shown below in example with all generic if any
If defined schema(as = ...) attribute now defines the prefix for the name of the component throughout OpenAPI references thus path that is possibly defined to request_body or responses bodywill not affect the name of the schema anymore.
This PR adds support for real generics which allows users to use deeply nested generic types as schemas without the alias hassle known to users. This commit will remove the old aliases support and implement completely new generics handling. (Something that many has been longing for long)
This commit further enhances the implementation for full generic support. From now on the full type paths need used to declare the types in the
OpenApi
and#[utoipa::path]
macros.As further elaborated here https://github.com/juhaku/utoipa/pull/1020#issue-2503474650 the name of the schema is now resolved form the type name and possible generic arguments or via
as = ...
attribute and possible generic arguments. This name is then used across the OpenApi. This makes it a single place to define the name or prefixed name for the type unlike previously the path of the schema inOpenApi
macro orrequest_body
orresponse body
was added to the name.This PR will also change the
schema!(...)
macro functionality to correctly generate schemas for arbitrary types even generic ones. Prior to this commit the generics where not resolved correctly. Still all generic arguments must implementToSchema
trait in order to generate schema in first place.Clean up the code and enhance documentation.
Breaking changes
schema(as = ...)
attribute now defines the prefix for the name of the component throughout OpenAPI references thus path that is possibly defined torequest_body
or responsesbody
will not affect the name of the schema anymore.Example of new syntax.
Fixes #703 Fixes #818 Fixes #574 Fixes #566 Fixes #861 Fixes #979 Fixes #503 Fixes #644 Fixes #790 Fixes #835 Fixes #817 Fixes #993 Fixes #961 Fixes #939 Fixes #729 Fixes #862
Closes #1020
Relates #751