You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 59339a9
Browse filesBrowse the repository at this point in the historyBrowse files
[kotlin-spring] Add clientRegistrationId option for declarative HTTP interface (#25013)
Mirror the Java spring generator's clientRegistrationId option (#22726) for
kotlin-spring with library=spring-declarative-http-interface. When set, the
generated interfaces are annotated with @ClientRegistrationId and the
spring-boot-starter-oauth2-client dependency is added to the Spring Boot 4
build files even if the spec declares no security schemes.
The option requires useSpringBoot4=true and is rejected for other libraries,
matching the Java generator. Output is unchanged when it is not set.
Fixes#24936
Copy file name to clipboardExpand all lines: docs/generators/kotlin-spring.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
27
27
|autoXSpringPaginated|Automatically add x-spring-paginated to operations that have the given set of pagination query parameters. 'page-size-sort' requires 'page', 'size', and 'sort'; 'page-size' requires only 'page' and 'size' (sort may be absent). Operations with x-spring-paginated explicitly set to false will not be auto-detected. The legacy values 'true' (alias for 'page-size-sort') and 'false' (alias for 'none') are deprecated and will be removed in a future release.|<dl><dt>**none**</dt><dd>Disable auto-detection.</dd><dt>**page-size-sort**</dt><dd>Require 'page', 'size', and 'sort' query parameters.</dd><dt>**page-size**</dt><dd>Require only 'page' and 'size' query parameters.</dd><dt>**true**</dt><dd>(deprecated) alias for 'page-size-sort'.</dd><dt>**false**</dt><dd>(deprecated) alias for 'none'.</dd></dl>|none|
28
28
|basePackage|base package (invokerPackage) for generated code||org.openapitools|
29
29
|beanQualifiers|Whether to add fully-qualifier class names as bean qualifiers in @Component and @RestController annotations. May be used to prevent bean names clash if multiple generated libraries (contexts) added to single project.||false|
30
+
|clientRegistrationId|Client registration ID for OAuth2 in Spring HTTP Interface (@ClientRegistrationId annotation). Requires library=spring-declarative-http-interface and useSpringBoot4=true (Spring Security 7).||null|
30
31
|companionObject|Whether to generate companion objects in data classes, enabling companion extensions.||false|
31
32
|configPackage|configuration package for generated code||org.openapitools.configuration|
32
33
|declarativeInterfaceReactiveMode|What type of reactive style to use in Spring Http declarative interface|<dl><dt>**coroutines**</dt><dd>Use kotlin-idiomatic 'suspend' functions</dd><dt>**reactor**</dt><dd>Use reactor return wrappers 'Mono' and 'Flux'</dd></dl>|coroutines|
cliOptions.add(CliOption.newString(CLIENT_REGISTRATION_ID, "Client registration ID for OAuth2 in Spring HTTP Interface (@ClientRegistrationId annotation). Requires library=" + SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY + " and useSpringBoot4=true (Spring Security 7)."));
if (clientRegistrationId != null && !clientRegistrationId.isEmpty()) {
817
+
if (!SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY.equals(library)) {
818
+
thrownewIllegalArgumentException(CLIENT_REGISTRATION_ID + " is only supported with the " + SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY + " library");
819
+
}
820
+
if (!isUseSpringBoot4()) {
821
+
thrownewIllegalArgumentException(CLIENT_REGISTRATION_ID + " requires " + USE_SPRING_BOOT4 + "=true because @ClientRegistrationId is provided by Spring Security 7");
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/apiInterface.mustache
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/buildGradle-sb4-Kts.mustache
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb4.mustache
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1510,6 +1510,67 @@ public void generateHttpInterfaceRendersOperationExtraAnnotation() throws Except
0 commit comments