utoipa
utoipa copied to clipboard
Unify `utoipa-gen` type parsing/schema production
Representations of types/paths which are parsed into schemas are spread throughout utoipa-gen
and their level of parsing support varies:
- https://github.com/juhaku/utoipa/blob/6cec1029f57e3fd81d6b2c7e4680c34e482060e6/utoipa-gen/src/ext.rs#L21
- https://github.com/juhaku/utoipa/blob/6cec1029f57e3fd81d6b2c7e4680c34e482060e6/utoipa-gen/src/ext/rocket.rs#L118
- https://github.com/juhaku/utoipa/blob/6cec1029f57e3fd81d6b2c7e4680c34e482060e6/utoipa-gen/src/ext/rocket.rs#L75
- https://github.com/juhaku/utoipa/blob/6cec1029f57e3fd81d6b2c7e4680c34e482060e6/utoipa-gen/src/lib.rs#L806 which is used in https://github.com/juhaku/utoipa/blob/6cec1029f57e3fd81d6b2c7e4680c34e482060e6/utoipa-gen/src/path/parameter.rs#L38
It would be good to unify these somehow if possible and gain more consistent parsing and schema production support.
Yes this is something that need to be addressed, Currently the implementation is quite spread out. I suggest that this would be postponed for sort time. Since the axum integration will actually address some of the issues here.
List of things should be done:
- Split extensions to seprate crates + create corelib crate which contains types needed by the extensions
- Move extension related tests to these new crates
- Try to use the
ComponentPart
to resolve the types if possible (since it is generic type). - Ultimately refactor the implementation so that it is generic over all extension as much as possible.
I'm now working on refactoring the extension related types to use one argument type and resolving logic across the extensions.
With further PR:s we could get rid of this type once and for all in and use ComponentPart
instead which would enable us more centralized control for parsing.
https://github.com/juhaku/utoipa/blob/6cec1029f57e3fd81d6b2c7e4680c34e482060e6/utoipa-gen/src/lib.rs#L806