From 037bccc134ff1c1013f23869fdc6ac34faf2cee5 Mon Sep 17 00:00:00 2001 From: Felix Hagemans Date: Tue, 20 Jun 2023 16:10:05 +0200 Subject: [PATCH] only include imports which are actually required for spring-cloud ClientConfiguration generator (closes #6683) --- .../spring-cloud/clientConfiguration.mustache | 20 ++++++++++++++----- .../spring-cloud/.swagger-codegen/VERSION | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 2 +- .../main/java/io/swagger/api/StoreApi.java | 2 +- .../src/main/java/io/swagger/api/UserApi.java | 2 +- .../configuration/ClientConfiguration.java | 8 -------- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache index 3e86330c91b..2db71a60fa2 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache @@ -1,22 +1,32 @@ package {{configPackage}}; -import feign.Logger; -import feign.auth.BasicAuthRequestInterceptor; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +{{#authMethods}} +{{#isBasic}} +import feign.auth.BasicAuthRequestInterceptor; +{{/isBasic}} +{{#isOAuth}} import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; -import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; +{{#isApplication}} import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; +{{/isApplication}} +{{#isCode}} import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; +{{/isCode}} +{{#isImplicit}} import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; +{{/isImplicit}} +{{#isPassword}} import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; -import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; +{{/isPassword}} +{{/isOAuth}} +{{/authMethods}} @Configuration @EnableConfigurationProperties diff --git a/samples/client/petstore/spring-cloud/.swagger-codegen/VERSION b/samples/client/petstore/spring-cloud/.swagger-codegen/VERSION index 3db08f94c8c..cfd1b966621 100644 --- a/samples/client/petstore/spring-cloud/.swagger-codegen/VERSION +++ b/samples/client/petstore/spring-cloud/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.22-SNAPSHOT \ No newline at end of file +2.4.33-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java index 2cb7ea981f0..d2e45f3def5 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (2.4.22-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (2.4.33-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java index 42e529d3dd3..1bb2f52dc0b 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (2.4.22-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (2.4.33-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java index 0634b683c07..da3d5069eb9 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (2.4.22-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (2.4.33-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/configuration/ClientConfiguration.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/configuration/ClientConfiguration.java index 7edb3820fc5..8a0675574d8 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/configuration/ClientConfiguration.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/configuration/ClientConfiguration.java @@ -1,7 +1,5 @@ package io.swagger.configuration; -import feign.Logger; -import feign.auth.BasicAuthRequestInterceptor; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -10,13 +8,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; -import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; -import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; -import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; -import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; -import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; @Configuration @EnableConfigurationProperties