From 08c849bf4e59bdd4de494106dc996c6c1e919c1d Mon Sep 17 00:00:00 2001 From: "Dinodev.cn" Date: Tue, 31 May 2022 23:34:05 +0800 Subject: [PATCH 1/2] bug: incorrect generic param for multi interfaces public interface CrudControllerBase, SRC extends CustomQuery> { // some code } public interface ExistsControllerBase, EQUERY extends CustomQuery> { @PostMapping("exist") default Response exist(@RequestBody PostBody req) { // some code } } @RestController @RequestMapping("/v1/{tenant_id:[0-9A-Z]+}/user") public class UserAdminController implements CrudControllerBase, ExistsControllerBase { // some code } the "requestBody" in "/v1/{tenant_id}/user/exist" path get incorrect schema: "schema": { "$ref": "#/components/schemas/PostBodyCustomQuery" } the correct schema should be: "schema": { "$ref": "#/components/schemas/PostBodyUserExistsQuery" } --- .../src/main/java/org/springdoc/core/ReturnTypeParser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java index f12218bf1..e87b782d0 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java @@ -166,6 +166,9 @@ static ResolvableType resolveVariable(TypeVariable typeVariable, ResolvableTy } } for (ResolvableType ifc : contextType.getInterfaces()) { + if(!ifc.getType().equals(typeVariable.getGenericDeclaration())){ + continue; + } resolvedType = resolveVariable(typeVariable, ifc); if (resolvedType.resolve() != null) { return resolvedType; From 040df710dbc8a89257adbd26a959a034933bbb28 Mon Sep 17 00:00:00 2001 From: "Dinodev.cn" Date: Sat, 4 Jun 2022 01:10:32 +0800 Subject: [PATCH 2/2] Update ReturnTypeParser.java --- .../src/main/java/org/springdoc/core/ReturnTypeParser.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java index e87b782d0..990063cc2 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java @@ -151,7 +151,7 @@ static void findTypeForGenerics(Class[] generics, Type[] typeArguments, Resol */ static ResolvableType resolveVariable(TypeVariable typeVariable, ResolvableType contextType) { ResolvableType resolvedType; - if (contextType.hasGenerics()) { + if (contextType.hasGenerics() && contextType.getRawClass().equals(typeVariable.getGenericDeclaration())){ resolvedType = ResolvableType.forType(typeVariable, contextType); if (resolvedType.resolve() != null) { return resolvedType; @@ -166,9 +166,6 @@ static ResolvableType resolveVariable(TypeVariable typeVariable, ResolvableTy } } for (ResolvableType ifc : contextType.getInterfaces()) { - if(!ifc.getType().equals(typeVariable.getGenericDeclaration())){ - continue; - } resolvedType = resolveVariable(typeVariable, ifc); if (resolvedType.resolve() != null) { return resolvedType;