@@ -108,58 +108,37 @@ public String getDescription() {
108108 }
109109 }
110110
111- @ Getter
112- @ Setter
111+ @ Getter @ Setter
113112 private String basePackage ;
114- @ Getter
115- @ Setter
113+ @ Getter @ Setter
116114 protected String configPackage ;
117- @ Getter
118- @ Setter
115+ @ Getter @ Setter
119116 private String invokerPackage ;
120- @ Getter
121- @ Setter
117+ @ Getter @ Setter
122118 private String serverPort = "8080" ;
123119 private String title = "OpenAPI Kotlin Spring" ;
124120 private boolean useBeanValidation = true ;
125- @ Setter
126- private boolean skipDefaultInterface = false ;
127- @ Setter
128- private boolean skipDefaultApiInterface = false ;
129- @ Setter
130- private boolean includeHttpRequestContext = false ;
131- @ Setter
132- private boolean skipDefaultDelegateInterface = false ;
133- @ Setter
134- private boolean exceptionHandler = true ;
135- @ Setter
136- private boolean gradleBuildFile = true ;
121+ @ Setter private boolean skipDefaultInterface = false ;
122+ @ Setter private boolean skipDefaultApiInterface = false ;
123+ @ Setter private boolean skipDefaultDelegateInterface = false ;
124+ @ Setter private boolean exceptionHandler = true ;
125+ @ Setter private boolean gradleBuildFile = true ;
137126 private boolean useSwaggerUI = true ;
138- @ Setter
139- private boolean serviceInterface = false ;
140- @ Setter
141- private boolean serviceImplementation = false ;
142- @ Getter
143- @ Setter
127+ @ Setter private boolean serviceInterface = false ;
128+ @ Setter private boolean serviceImplementation = false ;
129+ @ Getter @ Setter
144130 private boolean reactive = false ;
145- @ Getter
146- @ Setter
131+ @ Setter private boolean includeHttpRequestContext = false ;
132+ @ Getter @ Setter
147133 private boolean useFlowForArrayReturnType = true ;
148- @ Setter
149- private boolean interfaceOnly = false ;
150- @ Setter
151- protected boolean useFeignClientUrl = true ;
152- @ Setter
153- protected boolean useFeignClient = false ;
154- @ Setter
155- private boolean delegatePattern = false ;
156- @ Setter
157- protected boolean useTags = false ;
158- @ Setter
159- private boolean beanQualifiers = false ;
160-
161- @ Getter
162- @ Setter
134+ @ Setter private boolean interfaceOnly = false ;
135+ @ Setter protected boolean useFeignClientUrl = true ;
136+ @ Setter protected boolean useFeignClient = false ;
137+ @ Setter private boolean delegatePattern = false ;
138+ @ Setter protected boolean useTags = false ;
139+ @ Setter private boolean beanQualifiers = false ;
140+
141+ @ Getter @ Setter
163142 protected boolean useSpringBoot3 = false ;
164143 protected RequestMappingMode requestMappingMode = RequestMappingMode .controller ;
165144 private DocumentationProvider documentationProvider ;
@@ -227,10 +206,10 @@ public KotlinSpringServerCodegen() {
227206 addSwitch (GRADLE_BUILD_FILE , "generate a gradle build file using the Kotlin DSL" , gradleBuildFile );
228207 addSwitch (USE_SWAGGER_UI , "Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies" , useSwaggerUI );
229208 addSwitch (SERVICE_INTERFACE , "generate service interfaces to go alongside controllers. In most " +
230- "cases this option would be used to update an existing project, so not to override implementations. " +
231- "Useful to help facilitate the generation gap pattern" , serviceInterface );
209+ "cases this option would be used to update an existing project, so not to override implementations. " +
210+ "Useful to help facilitate the generation gap pattern" , serviceInterface );
232211 addSwitch (SERVICE_IMPLEMENTATION , "generate stub service implementations that extends service " +
233- "interfaces. If this is set to true service interfaces will also be generated" , serviceImplementation );
212+ "interfaces. If this is set to true service interfaces will also be generated" , serviceImplementation );
234213 addSwitch (USE_BEANVALIDATION , "Use BeanValidation API annotations to validate data types" , useBeanValidation );
235214 addSwitch (SKIP_DEFAULT_INTERFACE , "Whether to skip generation of default implementations for interfaces (Api interfaces or Delegate interfaces depending on the delegatePattern option)" , skipDefaultInterface );
236215 addSwitch (REACTIVE , "use coroutines for reactive behavior" , reactive );
@@ -331,7 +310,7 @@ public List<AnnotationLibrary> supportedAnnotationLibraries() {
331310 */
332311 private boolean selectedDocumentationProviderRequiresSwaggerUiBootstrap () {
333312 return getDocumentationProvider ().equals (DocumentationProvider .SPRINGFOX ) ||
334- getDocumentationProvider ().equals (DocumentationProvider .SOURCE );
313+ getDocumentationProvider ().equals (DocumentationProvider .SOURCE );
335314 }
336315
337316 public boolean getExceptionHandler () {
@@ -459,7 +438,7 @@ public void processOpts() {
459438
460439 // Set basePackage from invokerPackage
461440 if (!additionalProperties .containsKey (BASE_PACKAGE )
462- && additionalProperties .containsKey (CodegenConstants .INVOKER_PACKAGE )) {
441+ && additionalProperties .containsKey (CodegenConstants .INVOKER_PACKAGE )) {
463442 this .setBasePackage ((String ) additionalProperties .get (CodegenConstants .INVOKER_PACKAGE ));
464443 this .setInvokerPackage ((String ) additionalProperties .get (CodegenConstants .INVOKER_PACKAGE ));
465444 additionalProperties .put (BASE_PACKAGE , basePackage );
@@ -632,6 +611,7 @@ public void processOpts() {
632611
633612 supportingFiles .add (new SupportingFile ("README.mustache" , "" , "README.md" ));
634613
614+
635615 if (this .exceptionHandler && !library .equals (SPRING_CLOUD_LIBRARY )) {
636616 supportingFiles .add (new SupportingFile ("exceptions.mustache" ,
637617 sanitizeDirectory (sourceFolder + File .separator + apiPackage ), "Exceptions.kt" ));
@@ -739,16 +719,16 @@ public void processOpts() {
739719 }
740720
741721 switch (getRequestMappingMode ()) {
742- case api_interface :
743- additionalProperties .put (USE_REQUEST_MAPPING_ON_INTERFACE , true );
744- break ;
745- case controller :
746- additionalProperties .put (USE_REQUEST_MAPPING_ON_CONTROLLER , true );
747- break ;
748- case none :
749- additionalProperties .put (USE_REQUEST_MAPPING_ON_INTERFACE , false );
750- additionalProperties .put (USE_REQUEST_MAPPING_ON_CONTROLLER , false );
751- break ;
722+ case api_interface :
723+ additionalProperties .put (USE_REQUEST_MAPPING_ON_INTERFACE , true );
724+ break ;
725+ case controller :
726+ additionalProperties .put (USE_REQUEST_MAPPING_ON_CONTROLLER , true );
727+ break ;
728+ case none :
729+ additionalProperties .put (USE_REQUEST_MAPPING_ON_INTERFACE , false );
730+ additionalProperties .put (USE_REQUEST_MAPPING_ON_CONTROLLER , false );
731+ break ;
752732 }
753733
754734 // spring uses the jackson lib, and we disallow configuration.
@@ -798,7 +778,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
798778
799779 if (SPRING_BOOT .equals (library ) && ModelUtils .containsEnums (this .openAPI )) {
800780 supportingFiles .add (new SupportingFile ("converter.mustache" ,
801- (sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "EnumConverterConfiguration.kt" ));
781+ (sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "EnumConverterConfiguration.kt" ));
802782 }
803783
804784 if (!additionalProperties .containsKey (TITLE )) {
@@ -950,9 +930,9 @@ public void setReturnContainer(final String returnContainer) {
950930 operation .returnContainer = returnContainer ;
951931 }
952932 });
953- // if(implicitHeaders){
954- // removeHeadersFromAllParams(operation.allParams);
955- // }
933+ // if(implicitHeaders){
934+ // removeHeadersFromAllParams(operation.allParams);
935+ // }
956936 });
957937 }
958938
@@ -965,6 +945,7 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
965945 return objs ;
966946 }
967947
948+
968949 private String getNonMutableContainerTypeIfNeeded (String type ) {
969950 if (type != null && type .contains ("kotlin.collections.Mutable" )) {
970951 return type .replaceAll ("kotlin\\ .collections\\ .Mutable" , "kotlin.collections." );
@@ -978,7 +959,6 @@ private static String sanitizeDirectory(String in) {
978959
979960 // TODO could probably be made more generic, and moved to the `mustache` package if required by other components.
980961 private static class EscapeLambda implements Mustache .Lambda {
981-
982962 private final String from ;
983963 private final String to ;
984964
0 commit comments