Skip to content

Commit 54ea7b6

Browse files
committed
better name for switches
1 parent 5c02500 commit 54ea7b6

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

bin/configs/kotlin-spring-declarative-interface.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ additionalProperties:
1111
beanValidations: "true"
1212
interfaceOnly: false
1313
reactive: true
14-
wrapResponsesForDeclarativeInterface: true
14+
declarativeInterfaceWrapResponses: true
1515
useFlowForArrayReturnType: false
16-
declarativeModeReactiveMode: "reactor"
16+
declarativeInterfaceReactiveMode: "reactor"

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
8585
public static final String DELEGATE_PATTERN = "delegatePattern";
8686
public static final String USE_TAGS = "useTags";
8787
public static final String BEAN_QUALIFIERS = "beanQualifiers";
88-
public static final String WRAP_RESPONSES_FOR_DECLARATIVE_INTERFACE = "wrapResponsesForDeclarativeInterface";
89-
public static final String DECLARATIVE_MODE_REACTIVE_MODE = "declarativeModeReactiveMode";
88+
public static final String DECLARATIVE_INTERFACE_WRAP_RESPONSES = "declarativeInterfaceWrapResponses";
89+
public static final String DECLARATIVE_INTERFACE_REACTIVE_MODE = "declarativeInterfaceReactiveMode";
9090

9191
public static final String USE_SPRING_BOOT3 = "useSpringBoot3";
9292
public static final String USE_FLOW_FOR_ARRAY_RETURN_TYPE = "useFlowForArrayReturnType";
@@ -160,7 +160,7 @@ public String getDescription() {
160160
@Setter
161161
private boolean beanQualifiers = false;
162162
@Setter
163-
private boolean wrapResponsesForDeclarativeInterface = false;
163+
private boolean declarativeInterfaceWrapResponses = false;
164164

165165
@Getter
166166
@Setter
@@ -247,12 +247,12 @@ public KotlinSpringServerCodegen() {
247247
" (contexts) added to single project.", beanQualifiers);
248248
addSwitch(USE_SPRING_BOOT3, "Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.", useSpringBoot3);
249249
addSwitch(USE_FLOW_FOR_ARRAY_RETURN_TYPE, "Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.", useFlowForArrayReturnType);
250-
addSwitch(WRAP_RESPONSES_FOR_DECLARATIVE_INTERFACE,
250+
addSwitch(DECLARATIVE_INTERFACE_WRAP_RESPONSES,
251251
"Whether (when false) to return actual type (e.g. List<Fruit>) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>)",
252-
wrapResponsesForDeclarativeInterface);
253-
addSwitch(WRAP_RESPONSES_FOR_DECLARATIVE_INTERFACE,
252+
declarativeInterfaceWrapResponses);
253+
addSwitch(DECLARATIVE_INTERFACE_WRAP_RESPONSES,
254254
"Whether (when false) to return actual type (e.g. List<Fruit>) and handle non 2xx responses via exceptions or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>)",
255-
wrapResponsesForDeclarativeInterface);
255+
declarativeInterfaceWrapResponses);
256256

257257
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
258258
supportedLibraries.put(SPRING_CLOUD_LIBRARY,
@@ -564,15 +564,15 @@ public void processOpts() {
564564
throw new IllegalArgumentException("Additional property '" + USE_FLOW_FOR_ARRAY_RETURN_TYPE + "' must be set to 'false' as it is not supported by Spring declarative HTTP interface");
565565
}
566566
}
567-
if (additionalProperties.containsKey(DECLARATIVE_MODE_REACTIVE_MODE)) {
568-
this.reactiveMode = String.valueOf(additionalProperties.get(DECLARATIVE_MODE_REACTIVE_MODE));
567+
if (additionalProperties.containsKey(DECLARATIVE_INTERFACE_REACTIVE_MODE)) {
568+
this.reactiveMode = String.valueOf(additionalProperties.get(DECLARATIVE_INTERFACE_REACTIVE_MODE));
569569
}
570570
if ("coroutines".equalsIgnoreCase(reactiveMode)) {
571571
writePropertyBack("reactiveModeCoroutines", true);
572572
} else if ("reactor".equalsIgnoreCase(reactiveMode)) {
573573
writePropertyBack("reactiveModeReactor", true);
574574
} else {
575-
throw new IllegalArgumentException("Invalid value for additional property '" + DECLARATIVE_MODE_REACTIVE_MODE + "'. Supported values are 'coroutines' and 'reactor'.");
575+
throw new IllegalArgumentException("Invalid value for additional property '" + DECLARATIVE_INTERFACE_REACTIVE_MODE + "'. Supported values are 'coroutines' and 'reactor'.");
576576
}
577577
}
578578
}
@@ -832,7 +832,7 @@ protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
832832

833833
@Override
834834
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
835-
if (library.equals(SPRING_BOOT) && !useTags) {
835+
if ((library.equals(SPRING_BOOT) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY)) && !useTags) {
836836
String basePath = resourcePath;
837837
if (basePath.startsWith("/")) {
838838
basePath = basePath.substring(1);
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
{{! handle reactive map and array}}
22
{{#reactive}}
33
{{#isMap}}
4-
{{#reactiveModeReactor}}Mono<{{/reactiveModeReactor}}{{#wrapResponsesForDeclarativeInterface}}ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}Map<String, {{{returnType}}}>{{#wrapResponsesForDeclarativeInterface}}>{{/wrapResponsesForDeclarativeInterface}}{{#reactiveModeReactor}}>{{/reactiveModeReactor}}
4+
{{#reactiveModeReactor}}Mono<{{/reactiveModeReactor}}{{#declarativeInterfaceWrapResponses}}ResponseEntity<{{/declarativeInterfaceWrapResponses}}Map<String, {{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>{{/declarativeInterfaceWrapResponses}}{{#reactiveModeReactor}}>{{/reactiveModeReactor}}
55
{{/isMap}}
66
{{#isArray}}
77
{{! array handle reactive - reactor with/without ResponseEntity wrapper}}
88
{{#reactiveModeReactor}}
9-
{{#wrapResponsesForDeclarativeInterface}}Mono<ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}Flux<{{{returnType}}}>{{#wrapResponsesForDeclarativeInterface}}>>{{/wrapResponsesForDeclarativeInterface}}
9+
{{#declarativeInterfaceWrapResponses}}Mono<ResponseEntity<{{/declarativeInterfaceWrapResponses}}Flux<{{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>>{{/declarativeInterfaceWrapResponses}}
1010
{{/reactiveModeReactor}}
1111
{{! array handle reactive - coroutines with/without ResponseEntity wrapper}}
1212
{{#reactiveModeCoroutines}}
13-
{{#wrapResponsesForDeclarativeInterface}}ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}{{{returnContainer}}}<{{{returnType}}}>{{#wrapResponsesForDeclarativeInterface}}>{{/wrapResponsesForDeclarativeInterface}}
13+
{{#declarativeInterfaceWrapResponses}}ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnContainer}}}<{{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>{{/declarativeInterfaceWrapResponses}}
1414
{{/reactiveModeCoroutines}}
1515
{{/isArray}}
1616
{{! handle reactive non-container - with/without ResponseEntity wrapper}}
1717
{{^returnContainer}}
1818
{{#reactiveModeReactor}}
19-
Mono<{{#wrapResponsesForDeclarativeInterface}}ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}{{{returnType}}}{{#wrapResponsesForDeclarativeInterface}}>{{/wrapResponsesForDeclarativeInterface}}>
19+
Mono<{{#declarativeInterfaceWrapResponses}}ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnType}}}{{#declarativeInterfaceWrapResponses}}>{{/declarativeInterfaceWrapResponses}}>
2020
{{/reactiveModeReactor}}
2121
{{#reactiveModeCoroutines}}
22-
{{#wrapResponsesForDeclarativeInterface}}
23-
ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}{{{returnType}}}{{#wrapResponsesForDeclarativeInterface}}>
24-
{{/wrapResponsesForDeclarativeInterface}}
22+
{{#declarativeInterfaceWrapResponses}}
23+
ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnType}}}{{#declarativeInterfaceWrapResponses}}>
24+
{{/declarativeInterfaceWrapResponses}}
2525
{{/reactiveModeCoroutines}}
2626
{{/returnContainer}}
2727
{{/reactive}}
2828
{{^reactive}}
2929
{{! handle non-reactive map and array}}
3030
{{#isMap}}
31-
{{#wrapResponsesForDeclarativeInterface}}
32-
ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}Map<String, {{{returnType}}}>{{#wrapResponsesForDeclarativeInterface}}>
33-
{{/wrapResponsesForDeclarativeInterface}}
31+
{{#declarativeInterfaceWrapResponses}}
32+
ResponseEntity<{{/declarativeInterfaceWrapResponses}}Map<String, {{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>
33+
{{/declarativeInterfaceWrapResponses}}
3434
{{/isMap}}
3535
{{#isArray}}
3636
{{! array handle non-reactive - with/without ResponseEntity wrapper}}
37-
{{#wrapResponsesForDeclarativeInterface}}
38-
ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}{{{returnContainer}}}<{{{returnType}}}>{{#wrapResponsesForDeclarativeInterface}}>
39-
{{/wrapResponsesForDeclarativeInterface}}
37+
{{#declarativeInterfaceWrapResponses}}
38+
ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnContainer}}}<{{{returnType}}}>{{#declarativeInterfaceWrapResponses}}>
39+
{{/declarativeInterfaceWrapResponses}}
4040
{{/isArray}}
4141
{{! handle reactive non-container - with/without ResponseEntity wrapper}}
4242
{{^returnContainer}}
43-
{{#wrapResponsesForDeclarativeInterface}}
44-
ResponseEntity<{{/wrapResponsesForDeclarativeInterface}}{{{returnType}}}{{#wrapResponsesForDeclarativeInterface}}>
45-
{{/wrapResponsesForDeclarativeInterface}}
43+
{{#declarativeInterfaceWrapResponses}}
44+
ResponseEntity<{{/declarativeInterfaceWrapResponses}}{{{returnType}}}{{#declarativeInterfaceWrapResponses}}>
45+
{{/declarativeInterfaceWrapResponses}}
4646
{{/returnContainer}}
4747
{{/reactive}}

0 commit comments

Comments
 (0)