From 23afd3cdb7d9a7a558a5d7c01ee5c8df126baec5 Mon Sep 17 00:00:00 2001 From: Juha Kukkonen Date: Sat, 2 Nov 2024 17:08:58 +0200 Subject: [PATCH] Fix alias support for `IntoParams` (#1179) This commit fixes missing support for aliases defined via `utoipa-config` for `IntoParams` derive macro. Fixes #1176 --- utoipa-gen/CHANGELOG.md | 4 ++++ utoipa-gen/src/component/into_params.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/utoipa-gen/CHANGELOG.md b/utoipa-gen/CHANGELOG.md index fe9a12f2..dd3c4ffa 100644 --- a/utoipa-gen/CHANGELOG.md +++ b/utoipa-gen/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed + +* Fix alias support for `IntoParams` (https://github.com/juhaku/utoipa/pull/1179) + ### Changed * Added missing formats for `KnownFormat` parsing (https://github.com/juhaku/utoipa/pull/1178) diff --git a/utoipa-gen/src/component/into_params.rs b/utoipa-gen/src/component/into_params.rs index 084491ca..7f3868db 100644 --- a/utoipa-gen/src/component/into_params.rs +++ b/utoipa-gen/src/component/into_params.rs @@ -388,6 +388,9 @@ impl Param { .as_ref() .map_try(|value_type| value_type.as_type_tree())? .unwrap_or(type_tree); + let alias_type = component.get_alias_type()?; + let alias_type_tree = alias_type.as_ref().map_try(TypeTree::from_type)?; + let component = alias_type_tree.as_ref().unwrap_or(&component); let required: Option = pop_feature!(param_features => Feature::Required(_)).into_inner(); @@ -405,7 +408,7 @@ impl Param { tokens.extend(param_features.to_token_stream()?); let schema = ComponentSchema::new(component::ComponentSchemaProps { - type_tree: &component, + type_tree: component, features: schema_features, description: None, container: &Container { generics },