|
57 | 57 | import org.slf4j.Logger; |
58 | 58 | import org.slf4j.LoggerFactory; |
59 | 59 |
|
| 60 | +import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.USE_TAGS; |
| 61 | + |
60 | 62 | public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanValidationFeatures { |
61 | 63 |
|
62 | 64 | public static final String DEFAULT_LIBRARY = Constants.KTOR; |
@@ -85,7 +87,7 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa |
85 | 87 | private Boolean metricsFeatureEnabled = true; |
86 | 88 | private boolean interfaceOnly = false; |
87 | 89 | private boolean useBeanValidation = false; |
88 | | - private boolean useTags = false; |
| 90 | + private boolean useTags = true; |
89 | 91 | private boolean useCoroutines = false; |
90 | 92 | private boolean useMutiny = false; |
91 | 93 | private boolean returnResponse = false; |
@@ -193,7 +195,7 @@ public KotlinServerCodegen() { |
193 | 195 | addSwitch(Constants.METRICS, Constants.METRICS_DESC, getMetricsFeatureEnabled()); |
194 | 196 | addSwitch(Constants.INTERFACE_ONLY, Constants.INTERFACE_ONLY_DESC, interfaceOnly); |
195 | 197 | addSwitch(USE_BEANVALIDATION, Constants.USE_BEANVALIDATION_DESC, useBeanValidation); |
196 | | - addSwitch(USE_TAGS, USE_TAGS_DESC, useTags); |
| 198 | + addSwitch(USE_TAGS, Constants.USE_TAGS_DESC, useTags); |
197 | 199 | addSwitch(Constants.USE_COROUTINES, Constants.USE_COROUTINES_DESC, useCoroutines); |
198 | 200 | addSwitch(Constants.USE_MUTINY, Constants.USE_MUTINY_DESC, useMutiny); |
199 | 201 | addSwitch(Constants.RETURN_RESPONSE, Constants.RETURN_RESPONSE_DESC, returnResponse); |
@@ -426,6 +428,8 @@ public static class Constants { |
426 | 428 | public static final String IS_KTOR = "isKtor"; |
427 | 429 | public static final String FIX_JACKSON_JSON_TYPE_INFO_INHERITANCE = "fixJacksonJsonTypeInfoInheritance"; |
428 | 430 | public static final String FIX_JACKSON_JSON_TYPE_INFO_INHERITANCE_DESC = "When true (default), ensures Jackson polymorphism works correctly by: (1) always setting visible=true on @JsonTypeInfo, and (2) adding the discriminator property to child models with appropriate default values. When false, visible is only set to true if all children already define the discriminator property."; |
| 431 | + public static final String USE_TAGS = "useTags"; |
| 432 | + public static final String USE_TAGS_DESC = "use tags for creating interface and controller classnames. This option is currently supported only when using jaxrs-spec library."; |
429 | 433 | } |
430 | 434 |
|
431 | 435 | @Override |
@@ -730,16 +734,11 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera |
730 | 734 | return; |
731 | 735 | } |
732 | 736 |
|
733 | | - final String basePath = StringUtils.substringBefore(resourcePath.startsWith("/") ? resourcePath.substring(1) : resourcePath, "/"); |
734 | | - if (!StringUtils.isEmpty(basePath)) { |
735 | | - co.subresourceOperation = !co.path.isEmpty(); |
736 | | - } |
737 | | - co.baseName = basePath; |
738 | | - if (StringUtils.isEmpty(co.baseName) || co.baseName.chars().anyMatch(ch -> ch == '{' || ch == '}')) { |
739 | | - co.baseName = "default"; |
| 737 | + String basePath = StringUtils.substringBefore(resourcePath.startsWith("/") ? resourcePath.substring(1) : resourcePath, "/"); |
| 738 | + if (StringUtils.isEmpty(basePath) || basePath.chars().anyMatch(ch -> ch == '{' || ch == '}')) { |
| 739 | + basePath = "default"; |
740 | 740 | } |
741 | | - final List<CodegenOperation> opList = operations.computeIfAbsent(co.baseName, k -> new ArrayList<>()); |
742 | | - opList.add(co); |
| 741 | + super.addOperationToGroup(basePath, resourcePath, operation, co, operations); |
743 | 742 | } |
744 | 743 |
|
745 | 744 | @Override |
|
0 commit comments