diff --git a/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java b/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java index eaafded674..31d9fa8abf 100644 --- a/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java +++ b/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautJavaCodegen.java @@ -1582,7 +1582,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List models) { @@ -2398,7 +2398,7 @@ private void processProperty(CodegenProperty property, boolean isServer, Codegen property.maxLength = null; } - processGenericAnnotations(property, useBeanValidation, isGenerateHardNullable(), false, false, false, false, false); + processGenericAnnotations(property, useBeanValidation, isGenerateHardNullable(), false, false, false, false, false, false); normalizeExtraAnnotations(EXT_ANNOTATIONS_FIELD, false, property.vendorExtensions); normalizeExtraAnnotations(EXT_ANNOTATIONS_SETTER, false, property.vendorExtensions); @@ -2432,7 +2432,7 @@ private void processParentModel(CodegenModel model, List requir var parentVars = new ArrayList(); for (var v : parent.allVars) { if (notContainsProp(v, model.vars)) { - processGenericAnnotations(v, useBeanValidation, isGenerateHardNullable(), false, false, false, false, false); + processGenericAnnotations(v, useBeanValidation, isGenerateHardNullable(), false, false, false, false, false, false); parentVars.add(v); } } diff --git a/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautKotlinCodegen.java b/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautKotlinCodegen.java index f303a8e6a3..9140d8d72d 100644 --- a/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautKotlinCodegen.java +++ b/openapi-generator/src/main/java/io/micronaut/openapi/generator/AbstractMicronautKotlinCodegen.java @@ -112,6 +112,8 @@ import static io.micronaut.openapi.generator.Utils.calcQueryValueFormat; import static io.micronaut.openapi.generator.Utils.isDateType; import static io.micronaut.openapi.generator.Utils.normalizeExtraAnnotations; +import static io.micronaut.openapi.generator.Utils.normalizeStr; +import static io.micronaut.openapi.generator.Utils.normalizeStrValue; import static io.micronaut.openapi.generator.Utils.processDuplicateVars; import static io.micronaut.openapi.generator.Utils.processGenericAnnotations; import static io.micronaut.openapi.generator.Utils.readListOfStringsProperty; @@ -995,6 +997,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera List opList = operations.computeIfAbsent(basePath, k -> new ArrayList<>()); opList.add(co); co.baseName = basePath; + co.vendorExtensions.put("normalizedBaseName", normalizeStr(basePath)); return; } @@ -1004,6 +1007,12 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera } super.addOperationToGroup(superSanitizeTag(tag), resourcePath, operation, co, operations); + + var foundTag = co.tags.stream().filter(t -> t.getName().equals(tag)).findFirst().orElse(null); + co.vendorExtensions.put("normalizedBaseTag", normalizeStr(tag)); + if (foundTag != null) { + co.vendorExtensions.put("normalizedTagDesc", normalizeStr(foundTag.getDescription())); + } } @Override @@ -1121,6 +1130,9 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List) op.vendorExtensions.get("x-roles"); + var normalizedRoles = new ArrayList(roles.size()); + for (var role : roles) { + normalizedRoles.add(normalizeStr(role)); + } + op.vendorExtensions.put("x-roles-normalized", normalizedRoles); + } + + if (op.summary != null) { + op.vendorExtensions.put("summaryNormalized", normalizeStr(op.summary)); + } + if (op.notes != null) { + op.vendorExtensions.put("notesNormalized", normalizeStr(op.notes)); + } + if (op.tags != null) { + for (var tag : op.tags) { + tag.setName(normalizeStr(tag.getName())); + } + } + if (op.responses != null) { + for (var response : op.responses) { + response.vendorExtensions.put("messageNormalized", normalizeStr(response.message)); + } + } + if (op.produces != null) { + for (var produce : op.produces) { + produce.put("mediaTypeNormalized", normalizeStr(produce.get("mediaType"))); + } + } + if (op.consumes != null) { + for (var consume : op.consumes) { + consume.put("mediaTypeNormalized", normalizeStr(consume.get("mediaType"))); + } + } + if (op.vendorExtensions.containsKey("swaggerParams")) { + for (var swaggerParam : (List) op.vendorExtensions.get("swaggerParams")) { + swaggerParam.vendorExtensions.put("baseNameNormalized", normalizeStr(swaggerParam.baseName)); + swaggerParam.vendorExtensions.put("descriptionNormalized", normalizeStr(swaggerParam.description)); + } + } + if (op.authMethods != null) { + for (var authMethod : op.authMethods) { + authMethod.vendorExtensions.put("nameNormalized", normalizeStr(authMethod.name)); + if (authMethod.scopes != null) { + for (var scope : authMethod.scopes) { + scope.put("scopeNormalized", normalizeStr((String) scope.get("scope"))); + } + } + } + } + op.vendorExtensions.put("pathNormalized", normalizeStr(op.path)); + + if (op.allParams != null) { + for (var param : op.allParams) { + param.vendorExtensions.put("baseNameNormalized", normalizeStr(param.baseName)); + if (param.defaultValue != null) { + param.vendorExtensions.put("defaultValueNormalized", normalizeStr(param.defaultValue)); + } + normalizeStrValue("x-pattern-message", param.vendorExtensions); + normalizeStrValue("x-size-message", param.vendorExtensions); + normalizeStrValue("x-not-null-message", param.vendorExtensions); + normalizeStrValue("x-minimum-message", param.vendorExtensions); + normalizeStrValue("x-maximum-message", param.vendorExtensions); + } + } + } + /** * This method removes all implicit header parameters from the list of parameters. * @@ -1727,7 +1817,7 @@ public CodegenParameter fromParameter(Parameter p, Set imports) { if (realName.contains("`")) { realName = realName.replace("`", ""); } - parameter.vendorExtensions.put("realName", realName); + parameter.vendorExtensions.put("realName", normalizeStr(realName)); Schema parameterSchema; if (p.getSchema() != null) { @@ -1766,7 +1856,7 @@ public CodegenParameter fromParameter(Parameter p, Set imports) { if (ksp && !defaultValueInit.equals(NULL_STRING)) { parameter.isNullable = false; } - parameter.vendorExtensions.put("defaultValueInit", defaultValueInit); + parameter.vendorExtensions.put("defaultValueInit", normalizeStr(defaultValueInit)); parameter.vendorExtensions.put("defaultValueIsNotNull", !defaultValueInit.equals(NULL_STRING)); } @@ -1806,7 +1896,7 @@ public CodegenProperty fromProperty(String name, Schema schema, boolean required property.nameInCamelCase = camelize(realName, LOWERCASE_FIRST_LETTER); property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase); } - property.vendorExtensions.put("realName", realName); + property.vendorExtensions.put("realName", normalizeStr(realName)); if (schema != null && schema.get$ref() != null) { var refSchema = ModelUtils.getSchemaFromRefToSchemaWithProperties(openAPI, schema.get$ref()); @@ -1838,7 +1928,7 @@ public CodegenProperty fromProperty(String name, Schema schema, boolean required defaultValueInit = NULL_STRING; } if (defaultValueInit != null) { - property.vendorExtensions.put("defaultValueInit", defaultValueInit); + property.vendorExtensions.put("defaultValueInit", normalizeStr(defaultValueInit)); } return property; @@ -2173,6 +2263,10 @@ public Map postProcessAllModels(Map objs) model.vendorExtensions.put("requiredParentVarsWithoutDiscriminator", requiredParentVarsWithoutDiscriminator); } + if (model.vendorExtensions.containsKey("x-deprecated-message")) { + model.vendorExtensions.put("x-deprecated-message-normalized", normalizeStr((String) model.vendorExtensions.get("x-deprecated-message"))); + } + model.vendorExtensions.put("descriptionNormalized", normalizeStr(model.description)); model.vendorExtensions.put("requiredVarsWithoutDiscriminator", requiredVarsWithoutDiscriminator); model.vendorExtensions.put("requiredVars", requiredVars); model.vendorExtensions.put("withRequiredOrOptionalVars", !requiredVarsWithoutDiscriminator.isEmpty() || !optionalVars.isEmpty()); @@ -2340,10 +2434,11 @@ protected void updateEnumVarsWithExtensions(List> enumVars, var baseType = (String) vendorExtensions.get("baseType"); for (var enumVar : enumVars) { + var value = (String) enumVar.get("value"); if ((boolean) enumVar.get("isString")) { + enumVar.put("valueNormalized", normalizeStr(value)); continue; } - var value = (String) enumVar.get("value"); value = value.replace("\"", ""); if ("char".equals(baseType) && !value.startsWith("'")) { enumVar.put("value", "'" + value + "'"); @@ -2352,6 +2447,7 @@ protected void updateEnumVarsWithExtensions(List> enumVars, } else if ("byte".equalsIgnoreCase(baseType)) { enumVar.put("value", value); } + enumVar.put("valueNormalized", enumVar.get("value")); } } @@ -2459,6 +2555,22 @@ private void processOneOfModels(CodegenModel model, Collection models private void processProperty(CodegenProperty property, boolean isServer, CodegenModel model, Map models) { + property.vendorExtensions.put("baseNameNormalized", normalizeStr(property.baseName)); + if (property.example != null) { + property.vendorExtensions.put("exampleNormalized", normalizeStr(property.example)); + } + if (property.description != null) { + property.vendorExtensions.put("descriptionNormalized", normalizeStr(property.description)); + } + if (property.vendorExtensions.containsKey("x-deprecated-message")) { + property.vendorExtensions.put("x-deprecated-message-normalized", normalizeStr((String) property.vendorExtensions.get("x-deprecated-message"))); + } + normalizeStrValue("x-pattern-message", property.vendorExtensions); + normalizeStrValue("x-size-message", property.vendorExtensions); + normalizeStrValue("x-not-null-message", property.vendorExtensions); + normalizeStrValue("x-minimum-message", property.vendorExtensions); + normalizeStrValue("x-maximum-message", property.vendorExtensions); + property.vendorExtensions.put("withRequiredAndOptionalVars", model.vendorExtensions.get("withRequiredAndOptionalVars")); property.vendorExtensions.put("inRequiredArgsConstructor", !property.isReadOnly || isServer); property.vendorExtensions.put("isServer", isServer); @@ -2469,6 +2581,7 @@ private void processProperty(CodegenProperty property, boolean isServer, Codegen property.vendorExtensions.put("x-implements", model.vendorExtensions.get("x-implements")); if (NULL_STRING.equals(property.example)) { property.example = null; + property.vendorExtensions.remove("exampleNormalized"); } if (useBeanValidation && ( (!property.isContainer && property.isModel) @@ -2480,7 +2593,7 @@ private void processProperty(CodegenProperty property, boolean isServer, Codegen // check pattern property for date types: if set, need use this pattern as `@Format` annotation value if (isDateType(property.dataType)) { if (StringUtils.isNotEmpty(property.pattern)) { - property.vendorExtensions.put("formatPattern", property.pattern); + property.vendorExtensions.put("formatPattern", normalizeStr(property.pattern)); property.pattern = null; } property.minItems = null; @@ -2494,7 +2607,7 @@ private void processProperty(CodegenProperty property, boolean isServer, Codegen } processGenericAnnotations(property, useBeanValidation, false, property.isNullable || property.isDiscriminator, - property.required, property.isReadOnly, true, ksp); + property.required, property.isReadOnly, true, true, ksp); normalizeExtraAnnotations(EXT_ANNOTATIONS_FIELD, true, property.vendorExtensions); normalizeExtraAnnotations(EXT_ANNOTATIONS_SETTER, true, property.vendorExtensions); diff --git a/openapi-generator/src/main/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegen.java b/openapi-generator/src/main/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegen.java index bedc9e3a92..5aeb03e7c6 100644 --- a/openapi-generator/src/main/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegen.java +++ b/openapi-generator/src/main/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegen.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.Map; +import static io.micronaut.openapi.generator.Utils.normalizeStr; import static io.micronaut.openapi.generator.Utils.processMultipartBody; import static io.micronaut.openapi.generator.Utils.readListOfStringsProperty; @@ -62,6 +63,7 @@ public class KotlinMicronautClientCodegen extends AbstractMicronautKotlinCodegen public static final String AUTHORIZATION_FILTER_PATTERN_STYLE = "authorizationFilterPatternStyle"; public static final String BASE_PATH_SEPARATOR = "basePathSeparator"; public static final String CLIENT_ID = "clientId"; + public static final String CLIENT_ID_NORMALIZED = "clientIdNormalized"; public static final String NAME = "kotlin-micronaut-client"; @@ -154,6 +156,14 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List(); var alreadyAddedMultipartBodyImport = false; + var clientIdNormalized = normalizeStr(clientId); + + if (clientId != null) { + objs.put("clientIdNormalized", clientIdNormalized); + } + if (appName != null) { + objs.put("appNameNormalized", normalizeStr(appName)); + } for (CodegenOperation op : operationList) { postProcessMultipartParam(op, op.bodyParams, removedParams); @@ -185,7 +195,8 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List ANONYMOUS_ROLE; case AUTHORIZED_ROLE_KEY -> AUTHORIZED_ROLE; case DENY_ALL_ROLE_KEY -> DENY_ALL_ROLE; - default -> "\"" + escapeText(role) + "\""; + default -> "\"" + normalizeStr(escapeText(role)) + "\""; }).toList(); } diff --git a/openapi-generator/src/main/java/io/micronaut/openapi/generator/Utils.java b/openapi-generator/src/main/java/io/micronaut/openapi/generator/Utils.java index fb1707999c..464296caa4 100644 --- a/openapi-generator/src/main/java/io/micronaut/openapi/generator/Utils.java +++ b/openapi-generator/src/main/java/io/micronaut/openapi/generator/Utils.java @@ -114,7 +114,7 @@ public static Pair> processMultipartBody(CodegenOp public static void processGenericAnnotations(CodegenParameter parameter, boolean useBeanValidation, boolean isGenerateHardNullable, boolean isNullable, boolean isRequired, boolean isReadonly, boolean withNullablePostfix, - boolean ksp) { + boolean isKotlin, boolean ksp) { var ext = parameter.vendorExtensions; if (!ext.containsKey("isPrimitiveArray")) { ext.put("isPrimitiveArray", isJavaPrimitiveArray(parameter.dataType) || isKotlinPrimitiveArray(parameter.dataType)); @@ -122,16 +122,16 @@ public static void processGenericAnnotations(CodegenParameter parameter, boolean CodegenProperty items = parameter.isMap ? parameter.additionalProperties : parameter.items; String datatypeWithEnum = parameter.datatypeWithEnum == null ? parameter.dataType : parameter.datatypeWithEnum; processGenericAnnotations(parameter.dataType, datatypeWithEnum, parameter.isMap, parameter.containerTypeMapped, - items, parameter.vendorExtensions, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, ksp); + items, parameter.vendorExtensions, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, isKotlin, ksp); if (parameter.items != null) { - processGenericAnnotations(parameter.items, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, ksp); + processGenericAnnotations(parameter.items, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, isKotlin, ksp); } } public static void processGenericAnnotations(CodegenProperty property, boolean useBeanValidation, boolean isGenerateHardNullable, boolean isNullable, boolean isRequired, boolean isReadonly, boolean withNullablePostfix, - boolean ksp) { + boolean isKotlin, boolean ksp) { var ext = property.vendorExtensions; if (!ext.containsKey("isPrimitiveArray")) { ext.put("isPrimitiveArray", isJavaPrimitiveArray(property.dataType) || isKotlinPrimitiveArray(property.dataType)); @@ -139,25 +139,25 @@ public static void processGenericAnnotations(CodegenProperty property, boolean u CodegenProperty items = property.isMap ? property.additionalProperties : property.items; String datatypeWithEnum = property.datatypeWithEnum == null ? property.dataType : property.datatypeWithEnum; processGenericAnnotations(property.dataType, datatypeWithEnum, property.isMap, property.containerTypeMapped, - items, ext, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, ksp); + items, ext, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, isKotlin, ksp); if (property.items != null) { - processGenericAnnotations(property.items, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, ksp); + processGenericAnnotations(property.items, useBeanValidation, isGenerateHardNullable, isNullable, isRequired, isReadonly, withNullablePostfix, isKotlin, ksp); } } public static void processGenericAnnotations(String dataType, String dataTypeWithEnum, boolean isMap, String containerType, CodegenProperty itemsProp, Map ext, boolean useBeanValidation, boolean isGenerateHardNullable, boolean isNullable, boolean isRequired, boolean isReadonly, - boolean withNullablePostfix, boolean ksp) { + boolean withNullablePostfix, boolean isKotlin, boolean ksp) { String genericAnnotations = null; dataType = addAnnotationsToPrimitiveArray(dataType, isNullable, isRequired, isReadonly, isGenerateHardNullable); dataTypeWithEnum = addAnnotationsToPrimitiveArray(dataTypeWithEnum, isNullable, isRequired, isReadonly, isGenerateHardNullable); var typeWithGenericAnnotations = dataType; var typeWithEnumWithGenericAnnotations = dataTypeWithEnum; if (useBeanValidation && itemsProp != null && dataType.contains("<")) { - genericAnnotations = genericAnnotations(itemsProp, isGenerateHardNullable, ksp); - processGenericAnnotations(itemsProp, useBeanValidation, isGenerateHardNullable, itemsProp.isNullable, itemsProp.required, itemsProp.isReadOnly, withNullablePostfix, ksp); + genericAnnotations = genericAnnotations(itemsProp, isGenerateHardNullable, isKotlin, ksp); + processGenericAnnotations(itemsProp, useBeanValidation, isGenerateHardNullable, itemsProp.isNullable, itemsProp.required, itemsProp.isReadOnly, withNullablePostfix, isKotlin, ksp); if (isMap) { typeWithGenericAnnotations = "Map"; typeWithEnumWithGenericAnnotations = "Map"; @@ -216,7 +216,7 @@ private static boolean isKotlinPrimitiveArray(String dataType) { }; } - private static String genericAnnotations(CodegenProperty prop, boolean isGenerateHardNullable, boolean ksp) { + private static String genericAnnotations(CodegenProperty prop, boolean isGenerateHardNullable, boolean isKotlin, boolean ksp) { var type = prop.openApiType == null ? null : prop.openApiType.toLowerCase(); @@ -236,6 +236,13 @@ private static String genericAnnotations(CodegenProperty prop, boolean isGenerat var notNullMsg = (String) prop.vendorExtensions.get("x-not-null-message"); var minMsg = (String) prop.vendorExtensions.get("x-minimum-message"); var maxMsg = (String) prop.vendorExtensions.get("x-maximum-message"); + if (isKotlin) { + patternMsg = normalizeStr(patternMsg); + sizeMsg = normalizeStr(sizeMsg); + notNullMsg = normalizeStr(notNullMsg); + minMsg = normalizeStr(minMsg); + maxMsg = normalizeStr(maxMsg); + } if (StringUtils.isNotEmpty(prop.pattern) && !prop.isDate && !prop.isDateTime) { if ("email".equals(type) || "email".equalsIgnoreCase(prop.dataFormat) || prop.isEmail) { @@ -338,7 +345,7 @@ private static String genericAnnotations(CodegenProperty prop, boolean isGenerat result.append(" "); } else { result.append("@Min("); - if (minMsg != null) { + if (!isKotlin && minMsg != null) { result.append("value = "); } result.append(longNumber); @@ -352,7 +359,7 @@ private static String genericAnnotations(CodegenProperty prop, boolean isGenerat } } catch (Exception e) { result.append("@DecimalMin("); - if (prop.exclusiveMinimum || minMsg != null) { + if (!isKotlin && (prop.exclusiveMinimum || minMsg != null)) { result.append("value = "); } result.append('"').append(prop.minimum).append('"'); @@ -385,7 +392,7 @@ private static String genericAnnotations(CodegenProperty prop, boolean isGenerat result.append(" "); } else { result.append("@Max("); - if (maxMsg != null) { + if (!isKotlin && maxMsg != null) { result.append("value = "); } result.append(longNumber); @@ -400,7 +407,7 @@ private static String genericAnnotations(CodegenProperty prop, boolean isGenerat } } catch (Exception e) { result.append("@DecimalMax("); - if (prop.exclusiveMaximum || maxMsg != null) { + if (!isKotlin && (prop.exclusiveMaximum || maxMsg != null)) { result.append("value = "); } result.append('"').append(prop.maximum).append('"'); @@ -470,7 +477,23 @@ public static void addStrValueToEnum(List enumVars, boolean isNumeric) { value = "\"" + value + "\""; } varMap.put("strValue", value); + varMap.put("strValueNormalized", normalizeStr(value)); + } + } + + public static void normalizeStrValue(String key, Map exts) { + var value = exts.get(key); + if (value == null) { + return; + } + exts.put(key, normalizeStr(value.toString())); + } + + public static String normalizeStr(String str) { + if (str == null) { + return null; } + return str.replace("$", "\\$"); } public static String toApiName(String name, String prefix, String suffix) { diff --git a/openapi-generator/src/main/resources/templates/java-micronaut/common/operationAnnotations.mustache b/openapi-generator/src/main/resources/templates/java-micronaut/common/operationAnnotations.mustache index a7f366ec2f..34d7fda0bb 100644 --- a/openapi-generator/src/main/resources/templates/java-micronaut/common/operationAnnotations.mustache +++ b/openapi-generator/src/main/resources/templates/java-micronaut/common/operationAnnotations.mustache @@ -32,10 +32,10 @@ * @see {{{summary}}} Documentation {{/externalDocs}} */ - {{#generateSwagger2Annotations}} - {{#isDeprecated}} + {{#isDeprecated}} @Deprecated - {{/isDeprecated}} + {{/isDeprecated}} + {{#generateSwagger2Annotations}} @Operation( operationId = "{{{operationId}}}", {{#summary}} diff --git a/openapi-generator/src/main/resources/templates/java-micronaut/server/controller-interface.mustache b/openapi-generator/src/main/resources/templates/java-micronaut/server/controller-interface.mustache index df5c9db5a3..6726ca2872 100644 --- a/openapi-generator/src/main/resources/templates/java-micronaut/server/controller-interface.mustache +++ b/openapi-generator/src/main/resources/templates/java-micronaut/server/controller-interface.mustache @@ -47,7 +47,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; @Controller {{/generateControllerAsAbstract}} {{#generateSwagger2Annotations}} -@Tag(name = "{{{baseName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"The {{{baseName}}} API"{{/tagDescription}}) +@Tag(name = "{{{vendorExtensions.normalizedBaseTag}}}"{{#vendorExtensions.normalizedTagDesc}}, description = "{{{.}}}"{{/vendorExtensions.normalizedTagDesc}}) {{/generateSwagger2Annotations}} public interface {{classname}} { diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/api.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/api.mustache index 9c474f76bc..9b7553c888 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/api.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/api.mustache @@ -41,24 +41,24 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement {{#generatedAnnotation}} {{>common/generatedAnnotation}} {{/generatedAnnotation}} -@Client({{#configureClientId}}{{#clientPath}}id = {{/clientPath}}{{/configureClientId}}"{{#configureClientId}}{{clientId}}{{/configureClientId}}{{^configureClientId}}\${{openbrace}}{{{applicationName}}}{{basePathSeparator}}base-path{{closebrace}}{{/configureClientId}}"{{#configureClientId}}{{#clientPath}}, path = "\${{openbrace}}{{#configureClientId}}{{{clientId}}}{{/configureClientId}}{{^configureClientId}}{{{applicationName}}}{{/configureClientId}}{{basePathSeparator}}base-path{{closebrace}}"{{/clientPath}}{{/configureClientId}}) +@Client({{#configureClientId}}{{#clientPath}}id = {{/clientPath}}{{/configureClientId}}"{{#configureClientId}}{{{clientIdNormalized}}}{{/configureClientId}}{{^configureClientId}}\${{openbrace}}{{{applicationName}}}{{basePathSeparator}}base-path{{closebrace}}{{/configureClientId}}"{{#configureClientId}}{{#clientPath}}, path = "\${{openbrace}}{{#configureClientId}}{{{clientIdNormalized}}}{{/configureClientId}}{{^configureClientId}}{{{appNameNormalized}}}{{/configureClientId}}{{basePathSeparator}}base-path{{closebrace}}"{{/clientPath}}{{/configureClientId}}) interface {{classname}} { {{#operations}} {{#operation}} {{#formatNoEmptyLines}} {{>common/operationAnnotations}}{{! -}} @{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}("{{{path}}}") +}} @{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}("{{{vendorExtensions.pathNormalized}}}") {{^vendorExtensions.onlyDefaultProduceOrEmpty}} - {{#produces}}{{#-first}}@Consumes({{/-first}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/produces}} + {{#produces}}{{#-first}}@Consumes({{/-first}}"{{{mediaTypeNormalized}}}"{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/produces}} {{/vendorExtensions.onlyDefaultProduceOrEmpty}} {{^vendorExtensions.onlyDefaultConsumeOrEmpty}} - {{#consumes}}{{#-first}}@Produces({{/-first}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/consumes}} + {{#consumes}}{{#-first}}@Produces({{/-first}}"{{{mediaTypeNormalized}}}"{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/consumes}} {{/vendorExtensions.onlyDefaultConsumeOrEmpty}} {{!auth methods}} {{#configureAuth}} {{#authMethods}} - @Authorization("{{{name}}}"{{#isOAuth}}, scopes = [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]{{/isOAuth}}) + @Authorization("{{{vendorExtensions.nameNormalized}}}"{{#isOAuth}}, scopes = [{{#scopes}}"{{{scopeNormalized}}}"{{^-last}}, {{/-last}}{{/scopes}}]{{/isOAuth}}) {{/authMethods}} {{/configureAuth}} {{!the method definition}} @@ -73,3 +73,4 @@ interface {{classname}} { {{/operations}} } {{/formatOneEmptyLine}} + diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/cookieParams.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/cookieParams.mustache index 4fdeb50d2c..6e0e35b8e1 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/cookieParams.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/cookieParams.mustache @@ -1 +1 @@ -{{#isCookieParam}}@CookieValue("{{baseName}}"{{#defaultValue}}, defaultValue = "{{defaultValue}}"{{/defaultValue}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isCookieParam}} \ No newline at end of file +{{#isCookieParam}}@CookieValue("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isCookieParam}} \ No newline at end of file diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/headerParams.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/headerParams.mustache index 143325fbea..91db76c508 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/headerParams.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/headerParams.mustache @@ -1 +1 @@ -{{#isHeaderParam}}@Header("{{baseName}}"{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isHeaderParam}} \ No newline at end of file +{{#isHeaderParam}}@Header("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isHeaderParam}} \ No newline at end of file diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/pathParams.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/pathParams.mustache index ff3694f223..6d07c41b09 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/pathParams.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/pathParams.mustache @@ -1 +1 @@ -{{#isPathParam}}@PathVariable("{{baseName}}"{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isPathParam}} \ No newline at end of file +{{#isPathParam}}@PathVariable("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isPathParam}} \ No newline at end of file diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/queryParams.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/queryParams.mustache index e2872033f7..523ed87937 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/queryParams.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/queryParams.mustache @@ -1 +1 @@ -{{#isQueryParam}}@QueryValue("{{{baseName}}}"{{!default value}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{!validation and type}}{{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isQueryParam}} \ No newline at end of file +{{#isQueryParam}}@QueryValue("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{>common/params/validation}}{{>client/params/type}}{{{paramName}}}: {{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{#vendorExtensions.defaultValueInit}} = {{{.}}}{{/vendorExtensions.defaultValueInit}}{{^vendorExtensions.defaultValueInit}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{^required}} = null{{/required}}{{/isNullable}}{{/vendorExtensions.defaultValueInit}}{{/isQueryParam}} \ No newline at end of file diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/enum.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/enum.mustache index 708de3575f..b12e91c4d4 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/enum.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/enum.mustache @@ -8,7 +8,7 @@ {{/isDeprecated}} */ {{#isDeprecated}} -@Deprecated("{{#vendorExtensions.x-deprecated-message}}{{{.}}}{{/vendorExtensions.x-deprecated-message}}") +@Deprecated("{{#vendorExtensions.x-deprecated-message-normalized}}{{{.}}}{{/vendorExtensions.x-deprecated-message-normalized}}") {{/isDeprecated}} {{#withXml}} @XmlType(name="{{datatypeWithEnum}}") @@ -24,7 +24,8 @@ {{{.}}} {{/additionalEnumTypeAnnotations}} {{#nonPublicApi}}internal {{/nonPublicApi}}{{#formatSingleLine}}enum class {{>common/model/enumName}}{{/formatSingleLine}}( - @get:JsonValue val value: {{{dataType}}}, + @get:JsonValue + val value: {{{dataType}}}, ){{#vendorExtensions.x-implements}}{{#-first}} : {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { {{#allowableValues}} @@ -40,8 +41,8 @@ {{#deprecated}} @Deprecated("") {{/deprecated}} - @JsonProperty({{{strValue}}}) - {{{name}}}({{{value}}}),{{#-last}} + @JsonProperty({{{strValueNormalized}}}) + {{{name}}}({{{valueNormalized}}}),{{#-last}} ;{{/-last}} {{/enumVars}} {{/allowableValues}} @@ -88,3 +89,4 @@ {{/formatNoEmptyLines}} } } + diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/field_annotations.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/field_annotations.mustache index 875941a682..f52c67400b 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/field_annotations.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/field_annotations.mustache @@ -1,5 +1,5 @@ {{#deprecated}} - @Deprecated("{{#vendorExtensions.x-deprecated-message}}{{{.}}}{{/vendorExtensions.x-deprecated-message}}") + @Deprecated("{{#vendorExtensions.x-deprecated-message-normalized}}{{{.}}}{{/vendorExtensions.x-deprecated-message-normalized}}") {{/deprecated}} {{>common/params/validation_field}} {{#withXml}} @@ -24,7 +24,7 @@ {{/isXmlAttribute}} {{/withXml}} {{#generateSwagger2Annotations}} - @{{{vendorExtensions.fieldAnnPrefix}}}Schema(name = "{{{baseName}}}"{{#isReadOnly}}, accessMode = Schema.AccessMode.READ_ONLY{{/isReadOnly}}{{#example}}, example = "{{{.}}}"{{/example}}{{#description}}, description = "{{{.}}}"{{/description}}, requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}{{#deprecated}}, deprecated = true{{/deprecated}}) + @{{{vendorExtensions.fieldAnnPrefix}}}Schema(name = "{{{vendorExtensions.baseNameNormalized}}}"{{#isReadOnly}}, accessMode = Schema.AccessMode.READ_ONLY{{/isReadOnly}}{{#vendorExtensions.exampleNormalized}}, example = "{{{.}}}"{{/vendorExtensions.exampleNormalized}}{{#vendorExtensions.descriptionNormalized}}, description = "{{{.}}}"{{/vendorExtensions.descriptionNormalized}}, requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}{{#deprecated}}, deprecated = true{{/deprecated}}) {{/generateSwagger2Annotations}} {{#vendorExtensions.x-is-jackson-optional-nullable}} {{!Unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}} diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/pojo.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/pojo.mustache index 51ed322967..2cd7c66d99 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/pojo.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/pojo.mustache @@ -8,13 +8,13 @@ {{/isDeprecated}} */ {{#isDeprecated}} -@Deprecated("{{#vendorExtensions.x-deprecated-message}}{{{.}}}{{/vendorExtensions.x-deprecated-message}}") +@Deprecated("{{#vendorExtensions.x-deprecated-message-normalized}}{{{vendorExtensions.x-deprecated-message-normalized}}}{{/vendorExtensions.x-deprecated-message-normalized}}") {{/isDeprecated}} -{{#description}} +{{#vendorExtensions.descriptionNormalized}} {{#generateSwagger2Annotations}} -@Schema({{#vendorExtensions.realName}}name = "{{{vendorExtensions.realName}}}", {{/vendorExtensions.realName}}description = "{{{description}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}}) +@Schema({{#vendorExtensions.realName}}name = "{{{.}}}", {{/vendorExtensions.realName}}description = "{{{vendorExtensions.descriptionNormalized}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}}) {{/generateSwagger2Annotations}} -{{/description}} +{{/vendorExtensions.descriptionNormalized}} {{#micronaut_serde_jackson}} @Serdeable {{/micronaut_serde_jackson}} @@ -137,7 +137,7 @@ {{/serializableModel}} {{#vars}} - const val JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}" + const val JSON_PROPERTY_{{nameInSnakeCase}} = "{{vendorExtensions.baseNameNormalized}}" {{/vars}} } {{/vendorExtensions.hasOwnVars}} @@ -154,3 +154,4 @@ {{/serializableModel}} {{/vendorExtensions.hasOwnVars}} {{closebrace}} + diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/typeInfoAnnotation.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/typeInfoAnnotation.mustache index 609b49fdb0..002fd749ca 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/typeInfoAnnotation.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/model/typeInfoAnnotation.mustache @@ -8,7 +8,7 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "{{{discriminator.propertyBaseName}}}", visible = true) {{#vendorExtensions.hasMappedModels}} @JsonSubTypes({{#mappedModels}} - JsonSubTypes.Type(value = {{modelName}}::class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), + JsonSubTypes.Type({{modelName}}::class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), {{/mappedModels}}) {{/vendorExtensions.hasMappedModels}} {{/jackson}} diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/operationAnnotations.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/operationAnnotations.mustache index 84e92e412f..daa3a5f0d5 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/operationAnnotations.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/operationAnnotations.mustache @@ -26,45 +26,45 @@ * * @deprecated{{#vendorExtensions.x-deprecated-message}} {{{.}}}{{/vendorExtensions.x-deprecated-message}} {{/isDeprecated}} - {{#externalDocs}} - * {{{description}}} + {{#externalDocs}}{{#description}} + * {{{description}}}{{/description}} * * @see {{{summary}}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated("{{#vendorExtensions.x-deprecated-message-normalized}}{{{.}}}{{/vendorExtensions.x-deprecated-message-normalized}}") + {{/isDeprecated}} {{#generateSwagger2Annotations}} - {{#isDeprecated}} - @Deprecated("{{#vendorExtensions.x-deprecated-message}}{{{.}}}{{/vendorExtensions.x-deprecated-message}}") - {{/isDeprecated}} @Operation( operationId = "{{{operationId}}}", - {{#summary}} + {{#vendorExtensions.summaryNormalized}} summary = "{{{.}}}", - {{/summary}} - {{#notes}} + {{/vendorExtensions.summaryNormalized}} + {{#vendorExtensions.notesNormalized}} description = "{{{.}}}", - {{/notes}} + {{/vendorExtensions.notesNormalized}} {{#tags.1}} {{!generate only when at least 2 tags}} tags = [ {{#tags}}"{{name}}"{{^-last}}, {{/-last}}{{/tags}} ], {{/tags.1}} responses = [ {{#responses}} - ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [ + ApiResponse(responseCode = "{{{code}}}", description = "{{{vendorExtensions.messageNormalized}}}"{{#baseType}}, content = [ {{#produces}} - Content(mediaType = "{{{mediaType}}}", {{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class){{#isArray}}){{/isArray}}), + Content(mediaType = "{{{mediaTypeNormalized}}}", {{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class){{#isArray}}){{/isArray}}), {{/produces}} ]{{/baseType}}), {{/responses}} ],{{#vendorExtensions.hasNotBodyParam}} parameters = [ {{#vendorExtensions.swaggerParams}} - Parameter(name = "{{baseName}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}}{{#description}}, description = "{{{description}}}"{{/description}}{{#required}}, required = true{{/required}}, `in` = ParameterIn.{{#isCookieParam}}COOKIE{{/isCookieParam}}{{#isHeaderParam}}HEADER{{/isHeaderParam}}{{#isQueryParam}}QUERY{{/isQueryParam}}{{#isPathParam}}PATH{{/isPathParam}}), + Parameter(name = "{{{vendorExtensions.baseNameNormalized}}}"{{#isDeprecated}}, deprecated = true{{/isDeprecated}}{{#vendorExtensions.descriptionNormalized}}, description = "{{{.}}}"{{/vendorExtensions.descriptionNormalized}}{{#required}}, required = true{{/required}}, `in` = ParameterIn.{{#isCookieParam}}COOKIE{{/isCookieParam}}{{#isHeaderParam}}HEADER{{/isHeaderParam}}{{#isQueryParam}}QUERY{{/isQueryParam}}{{#isPathParam}}PATH{{/isPathParam}}), {{/vendorExtensions.swaggerParams}} ],{{/vendorExtensions.hasNotBodyParam}}{{#hasAuthMethods}} security = [ {{#authMethods}} - SecurityRequirement(name = "{{name}}"{{#isOAuth}}{{#scopes.1}}, scopes = [{{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}}]{{/scopes.1}}{{/isOAuth}}), + SecurityRequirement(name = "{{{vendorExtensions.nameNormalized}}}"{{#isOAuth}}{{#scopes.1}}, scopes = [{{#scopes}}"{{{scopeNormalized}}}"{{^-last}}, {{/-last}}{{/scopes}}]{{/scopes.1}}{{/isOAuth}}), {{/authMethods}} ],{{/hasAuthMethods}} ) diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation.mustache index 88dd2494c9..fa8d097eec 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation.mustache @@ -66,27 +66,27 @@ {{/isEmail}} {{#isInteger}} {{#minimum}} - @Min({{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{{.}}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) + @Min({{{.}}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) {{/minimum}} {{#maximum}} - @Max({{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{{.}}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) + @Max({{{.}}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) {{/maximum}} {{/isInteger}} {{#isLong}} {{#minimum}} - @Min({{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{{.}}}L{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) + @Min({{{.}}}L{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) {{/minimum}} {{#maximum}} - @Max({{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{{.}}}L{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) + @Max({{{.}}}L{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) {{/maximum}} {{/isLong}} {{^isInteger}} {{^isLong}} {{#minimum}} - @DecimalMin({{#exclusiveMinimum}}value = {{/exclusiveMinimum}}{{^exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}}, inclusive = false{{/exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) + @DecimalMin("{{minimum}}"{{#exclusiveMinimum}}, inclusive = false{{/exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) {{/minimum}} {{#maximum}} - @DecimalMax({{#exclusiveMaximum}}value = {{/exclusiveMaximum}}{{^exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}}, inclusive = false{{/exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) + @DecimalMax("{{maximum}}"{{#exclusiveMaximum}}, inclusive = false{{/exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) {{/maximum}} {{/isLong}} {{/isInteger}} diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation_field.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation_field.mustache index e4ead521e1..e8b0de4d5e 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation_field.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/common/params/validation_field.mustache @@ -62,27 +62,27 @@ {{/isEmail}} {{#isInteger}} {{#minimum}} - @{{{vendorExtensions.fieldAnnPrefix}}}Min({{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{{.}}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) + @{{{vendorExtensions.fieldAnnPrefix}}}Min({{{.}}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) {{/minimum}} {{#maximum}} - @{{{vendorExtensions.fieldAnnPrefix}}}Max({{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{{.}}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) + @{{{vendorExtensions.fieldAnnPrefix}}}Max({{{.}}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) {{/maximum}} {{/isInteger}} {{#isLong}} {{#minimum}} - @{{{vendorExtensions.fieldAnnPrefix}}}Min({{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{{.}}}L{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) + @{{{vendorExtensions.fieldAnnPrefix}}}Min({{{.}}}L{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) {{/minimum}} {{#maximum}} - @{{{vendorExtensions.fieldAnnPrefix}}}Max({{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{{.}}}L{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) + @{{{vendorExtensions.fieldAnnPrefix}}}Max({{{.}}}L{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) {{/maximum}} {{/isLong}} {{^isInteger}} {{^isLong}} {{#minimum}} - @{{{vendorExtensions.fieldAnnPrefix}}}DecimalMin({{#exclusiveMinimum}}value = {{/exclusiveMinimum}}{{^exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}value = {{/vendorExtensions.x-minimum-message}}{{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}}, inclusive = false{{/exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) + @{{{vendorExtensions.fieldAnnPrefix}}}DecimalMin("{{minimum}}"{{#exclusiveMinimum}}, inclusive = false{{/exclusiveMinimum}}{{#vendorExtensions.x-minimum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-minimum-message}}) {{/minimum}} {{#maximum}} - @{{{vendorExtensions.fieldAnnPrefix}}}DecimalMax({{#exclusiveMaximum}}value = {{/exclusiveMaximum}}{{^exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}value = {{/vendorExtensions.x-maximum-message}}{{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}}, inclusive = false{{/exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) + @{{{vendorExtensions.fieldAnnPrefix}}}DecimalMax("{{maximum}}"{{#exclusiveMaximum}}, inclusive = false{{/exclusiveMaximum}}{{#vendorExtensions.x-maximum-message}}, message = "{{{.}}}"{{/vendorExtensions.x-maximum-message}}) {{/maximum}} {{/isLong}} {{/isInteger}} diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/controller-interface.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/controller-interface.mustache index abe979e163..16eca4e03c 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/controller-interface.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/controller-interface.mustache @@ -43,7 +43,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement @Controller {{/generateControllerAsAbstract}} {{#generateSwagger2Annotations}} -@Tag(name = "{{{baseName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"The {{{baseName}}} API"{{/tagDescription}}) +@Tag(name = "{{{normalizedBaseTag}}}"{{#normalizedTagDesc}}, description = "{{{.}}}"{{/normalizedTagDesc}}) {{/generateSwagger2Annotations}} interface {{classname}} { @@ -51,16 +51,16 @@ interface {{classname}} { {{#operation}} {{#formatNoEmptyLines}} {{>common/operationAnnotations}} - @{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}("{{{path}}}") + @{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}("{{{vendorExtensions.pathNormalized}}}") {{^vendorExtensions.onlyDefaultProduceOrEmpty}} - @Produces({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}) + @Produces({{#produces}}"{{{mediaTypeNormalized}}}"{{^-last}}, {{/-last}}{{/produces}}) {{/vendorExtensions.onlyDefaultProduceOrEmpty}} {{^vendorExtensions.onlyDefaultConsumeOrEmpty}} - @Consumes({{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}) + @Consumes({{#consumes}}"{{{mediaTypeNormalized}}}"{{^-last}}, {{/-last}}{{/consumes}}) {{/vendorExtensions.onlyDefaultConsumeOrEmpty}} {{!security annotations}} {{#useAuth}} - @Secured({{#vendorExtensions.x-roles}}{{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-roles}}) + @Secured({{#vendorExtensions.x-roles-normalized}}{{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-roles-normalized}}) {{/useAuth}} {{!the method definition}} {{#vendorExtensions.x-operation-extra-annotation}} @@ -74,7 +74,7 @@ interface {{classname}} { {{^vendorExtensions.formatPattern}} {{#isDateTime}}{{#dateTimeFormat}}@Format("{{{dateTimeFormat}}}"){{/dateTimeFormat}}{{/isDateTime}} {{#isDate}}{{#dateFormat}}@Format("{{{dateFormat}}}"){{/dateFormat}}{{/isDate}} - {{^isDateTime}}{{^isDate}}{{#vendorExtensions.format}}@Format({{{vendorExtensions.format}}}) {{/vendorExtensions.format}}{{/isDate}}{{/isDateTime}} + {{^isDateTime}}{{^isDate}}{{#vendorExtensions.format}}@Format({{{.}}}) {{/vendorExtensions.format}}{{/isDate}}{{/isDateTime}} {{/vendorExtensions.formatPattern}} {{#isDeprecated}} @java.lang.Deprecated diff --git a/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/params/annotations.mustache b/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/params/annotations.mustache index 75da825d0f..4dd4f61f91 100644 --- a/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/params/annotations.mustache +++ b/openapi-generator/src/main/resources/templates/kotlin-micronaut/server/params/annotations.mustache @@ -1,16 +1,16 @@ {{#isQueryParam}} - @QueryValue("{{{baseName}}}"{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) + @QueryValue("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{/isQueryParam}} {{#isPathParam}} - @PathVariable("{{baseName}}"{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) + @PathVariable("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{/isPathParam}} {{#isHeaderParam}} - @Header("{{baseName}}"{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) + @Header("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{/isHeaderParam}} {{#isBodyParam}} {{#vendorExtensions.isPart}} - @Part("{{baseName}}") + @Part("{{{vendorExtensions.baseNameNormalized}}}") {{/vendorExtensions.isPart}} {{^vendorExtensions.isPart}} @Body @@ -19,5 +19,5 @@ {{#isFormParam}} {{/isFormParam}} {{#isCookieParam}} - @CookieValue("{{baseName}}"{{#defaultValue}}, defaultValue = "{{defaultValue}}"{{/defaultValue}}) + @CookieValue("{{{vendorExtensions.baseNameNormalized}}}"{{#vendorExtensions.defaultValueNormalized}}, defaultValue = "{{{.}}}"{{/vendorExtensions.defaultValueNormalized}}) {{/isCookieParam}} diff --git a/openapi-generator/src/test/java/io/micronaut/openapi/generator/AbstractMicronautCodegenTest.java b/openapi-generator/src/test/java/io/micronaut/openapi/generator/AbstractMicronautCodegenTest.java index 964aa7f9f2..b6d707267b 100644 --- a/openapi-generator/src/test/java/io/micronaut/openapi/generator/AbstractMicronautCodegenTest.java +++ b/openapi-generator/src/test/java/io/micronaut/openapi/generator/AbstractMicronautCodegenTest.java @@ -34,10 +34,10 @@ public abstract class AbstractMicronautCodegenTest { protected final String PETSTORE_PATH = "src/test/resources/petstore.json"; /** - * @param codegen - the code generator + * @param codegen the code generator * @param opts codegen options - * @param configPath - the path to the config starting from src/test/resources - * @param filesToGenerate - which files to generate - can be CodegenConstants. MODELS, APIS, SUPPORTING_FILES, ... + * @param configPath the path to the config starting from src/test/resources + * @param filesToGenerate which files to generate - can be CodegenConstants. MODELS, APIS, SUPPORTING_FILES, ... * * @return - the path to the generated folder */ @@ -82,10 +82,10 @@ protected String generateWithOpts(MicronautCodeGenerator codegen, Map codegen, String configPath) { return generateFiles(codegen, configPath, true, SUPPORTING_FILES, APIS, MODELS); @@ -94,21 +94,21 @@ protected String generateFiles(MicronautCodeGenerator codegen, String configP /** * Generate standard set of file types: SUPPORTING_FILES, APIS, MODELS. * - * @param codegen - the code generator + * @param codegen the code generator * @param withCompile with compilation of generated files - * @param configPath - the path to the config starting from src/test/resources + * @param configPath the path to the config starting from src/test/resources * - * @return - the path to the generated folder + * @return the path to the generated folder */ protected String generateFiles(MicronautCodeGenerator codegen, String configPath, boolean withCompile) { return generateFiles(codegen, configPath, withCompile, SUPPORTING_FILES, APIS, MODELS); } /** - * @param codegen - the code generator - * @param configPath - the path to the config starting from src/test/resources + * @param codegen the code generator + * @param configPath the path to the config starting from src/test/resources * @param withCompile with compilation of generated files - * @param filesToGenerate - which files to generate - can be CodegenConstants. MODELS, APIS, SUPPORTING_FILES, ... + * @param filesToGenerate which files to generate - can be CodegenConstants. MODELS, APIS, SUPPORTING_FILES, ... * * @return - the path to the generated folder */ @@ -153,9 +153,9 @@ public static void assertFilesCompile(String directory, SourceFile... extraSourc /** * Compile files using the kotlin compiler and assert the compilation succeeded * - * @param directory - path of a directory of generated files to be compiled - * @param jvmTarget - jvmTarget version to compile to - * @param extraSourceFiles - extra source files to add to the compilation - useful for adding dummy types + * @param directory path of a directory of generated files to be compiled + * @param jvmTarget jvmTarget version to compile to + * @param extraSourceFiles extra source files to add to the compilation - useful for adding dummy types */ public static void assertFilesCompile(String directory, String jvmTarget, SourceFile... extraSourceFiles) { var sourceFiles = new ArrayList(); diff --git a/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegenTest.java b/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegenTest.java index 5785931b7f..e9e6c78fd9 100644 --- a/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegenTest.java +++ b/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautClientCodegenTest.java @@ -1160,13 +1160,13 @@ void testCustomValidationMessages() { @QueryValue("strParam3") @NotNull @Format(FORMAT_MULTI) strParam3: List<@Pattern(regexp = "my_pattern", message = "This is string pattern message") @Size(max = 10, message = "This is min max string length message") @NotNull(message = "This is required string message") String>, """, """ - @QueryValue("intParam") @NotNull @Format(FORMAT_MULTI) intParam: List<@NotNull(message = "This is required int message") @Min(value = 5, message = "This is min message") @Max(value = 10, message = "This is max message") Int>, + @QueryValue("intParam") @NotNull @Format(FORMAT_MULTI) intParam: List<@NotNull(message = "This is required int message") @Min(5, message = "This is min message") @Max(10, message = "This is max message") Int>, """, """ - @QueryValue("decimalParam") @NotNull @Format(FORMAT_MULTI) decimalParam: List<@NotNull(message = "This is required decimal message") @DecimalMin(value = "5.5", message = "This is decimal min message") @DecimalMax(value = "10.5", message = "This is decimal max message") BigDecimal>, + @QueryValue("decimalParam") @NotNull @Format(FORMAT_MULTI) decimalParam: List<@NotNull(message = "This is required decimal message") @DecimalMin("5.5", message = "This is decimal min message") @DecimalMax("10.5", message = "This is decimal max message") BigDecimal>, """, """ - @QueryValue("decimalParam2") @NotNull(message = "This is required param message") @Format(FORMAT_MULTI) decimalParam2: List<@NotNull(message = "This is required decimal message") @DecimalMin(value = "5.5", inclusive = false, message = "This is decimal min message") @DecimalMax(value = "10.5", inclusive = false, message = "This is decimal max message") BigDecimal>, + @QueryValue("decimalParam2") @NotNull(message = "This is required param message") @Format(FORMAT_MULTI) decimalParam2: List<@NotNull(message = "This is required decimal message") @DecimalMin("5.5", inclusive = false, message = "This is decimal min message") @DecimalMax("10.5", inclusive = false, message = "This is decimal max message") BigDecimal>, """, """ @QueryValue("positiveParam") @NotNull @Format(FORMAT_MULTI) positiveParam: List<@NotNull(message = "This is required int message") @Positive(message = "This is positive message") Int>, @@ -1198,8 +1198,8 @@ void testCustomValidationMessages() { """, """ @field:NotNull(message = "This is required int message") - @field:Min(value = 5, message = "This is min message") - @field:Max(value = 10, message = "This is max message") + @field:Min(5, message = "This is min message") + @field:Max(10, message = "This is max message") @field:JsonProperty(JSON_PROPERTY_INT_PROP) var intProp: Int, """, @@ -1221,44 +1221,44 @@ void testCustomValidationMessages() { """, """ @field:Nullable - @field:Min(value = 0, message = "This is positive message") + @field:Min(0, message = "This is positive message") @field:JsonProperty(JSON_PROPERTY_POSITIVE_PROP) @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) var positiveProp: Int? = null, """, """ @field:Nullable - @field:Min(value = 0, message = "This is positive or zero message") + @field:Min(0, message = "This is positive or zero message") @field:JsonProperty(JSON_PROPERTY_POSITIVE_OR_ZERO_PROP) @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) var positiveOrZeroProp: Int? = null, """, """ @field:Nullable - @field:Max(value = 0, message = "This is negative message") + @field:Max(0, message = "This is negative message") @field:JsonProperty(JSON_PROPERTY_NEGATIVE_PROP) @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) var negativeProp: Int? = null, """, """ @field:Nullable - @field:Max(value = 0, message = "This is negative or zero message") + @field:Max(0, message = "This is negative or zero message") @field:JsonProperty(JSON_PROPERTY_NEGATIVE_OR_ZERO_PROP) @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) var negativeOrZeroProp: Int? = null, """, """ @field:Nullable - @field:DecimalMin(value = "5.5", message = "This is decimal min message") - @field:DecimalMax(value = "10.5", message = "This is decimal max message") + @field:DecimalMin("5.5", message = "This is decimal min message") + @field:DecimalMax("10.5", message = "This is decimal max message") @field:JsonProperty(JSON_PROPERTY_DECIMAL_PROP) @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) var decimalProp: BigDecimal? = null, """, """ @field:Nullable - @field:DecimalMin(value = "5.5", inclusive = false, message = "This is decimal min message") - @field:DecimalMax(value = "10.5", inclusive = false, message = "This is decimal max message") + @field:DecimalMin("5.5", inclusive = false, message = "This is decimal min message") + @field:DecimalMax("10.5", inclusive = false, message = "This is decimal max message") @field:JsonProperty(JSON_PROPERTY_DECIMAL_PROP2) @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) var decimalProp2: BigDecimal? = null, @@ -2153,7 +2153,7 @@ void testJvmRecordWithInheritance() { assertFileContains(modelPath + "BookInfo.kt", """ @JsonSubTypes( - JsonSubTypes.Type(value = ExtendedBookInfo::class, name = "EXTENDED"), + JsonSubTypes.Type(ExtendedBookInfo::class, name = "EXTENDED"), ) open class BookInfo( @@ -2408,4 +2408,99 @@ void testHtmlDescription() { """ ); } + + @Test + void testDollarSign() { + + var codegen = new KotlinMicronautClientCodegen(); + codegen.setClientId("$myClientId"); + codegen.setClientPath(true); + codegen.setConfigureAuthorization(true); + codegen.setGenerateOperationOnlyForFirstTag(true); + codegen.setAuthFilterClientIds("$myClientId"); + codegen.setAuthFilterExcludedClientIds("$notMyClientId"); + codegen.setBasePathSeparator("$sep"); + String outputPath = generateFiles(codegen, "src/test/resources/3_0/dollar-sign.yml"); + + String path = outputPath + "src/main/kotlin/org/openapitools/"; + assertFileContains(path + "api/Tag1Api.kt", + """ + @Client(id = "\\$myClientId", path = "\\${\\$myClientId\\$sepbase-path}") + interface Tag1Api { + + /** + * {@summary summary with $dollarSign} + * contains $strings + * + * @param dollarPathVar desc pathVar with $dollarSign (required) + * @param schemaTitleWithDollarDollarSign Request body desc with $dollarSign (required) + * @param dollarQueryVar desc queryVar with $dollarSign (optional, default to ref2/$ref) + * Deprecated: Deprecated message with $dollarSign + * @param dollarHeaderVar desc header with $dollarSign (optional, default to $dollar) + * @param dollarCookieVar desc cookie with $dollarSign (optional, default to $dollar) + * @param dollarPropDouble (optional) + * @param dollarPropLong (optional) + * @param dollarPropInt (optional) + * @param dollarPropEmail (optional) + * @param dollarPropListMinMax (optional) + * @param dollarPropListMin (optional) + * @param dollarPropListMax (optional) + * @param dollarPropStrMinMax (optional) + * @param dollarPropStrMin (optional) + * @param dollarPropStrMax (optional) + * @param dollarPropStrPattern (optional) + * + * @return desc resp 200 with $dollarSign (status code 200) + * or desc resp 404 with $dollarSign (status code 404) + * + * @deprecated Deprecated message with $dollarSign + * + * @see summary with $dollarSign Documentation + */ + @Deprecated("Deprecated message with \\$dollarSign") + @Get("/\\$paths/{\\$pathVar}") + @Consumes("\\$application/json") + @Produces("\\$application/json") + @Authorization("\\$notSimpleAuth") + @Authorization("\\$OAuth2", scopes = ["\\$read", "\\$write"]) + fun getStrings( + @PathVariable("\\$pathVar", defaultValue = "\\$dollar") @NotNull dollarPathVar: String = "\\$dollar", + @Body @NotNull @Valid schemaTitleWithDollarDollarSign: SchemaTitleWithDollarDollarSign, + @QueryValue("\\$queryVar", defaultValue = "ref2/\\$ref") @Nullable @java.lang.Deprecated dollarQueryVar: DollarGetDollarStringsDollarQueryVarParameter? = DollarGetDollarStringsDollarQueryVarParameter.REF2__REF, + @Header("\\$headerVar", defaultValue = "\\$dollar") @Nullable dollarHeaderVar: String? = "\\$dollar", + @CookieValue("\\$cookieVar", defaultValue = "\\$dollar") @Nullable dollarCookieVar: String? = "\\$dollar", + @QueryValue("\\$propDouble") @Nullable @DecimalMin("10", message = "Message with \\$dollarSign") @DecimalMax("100", message = "Message with \\$dollarSign") dollarPropDouble: BigDecimal? = null, + @QueryValue("\\$propLong") @Nullable @Min(10L, message = "Message with \\$dollarSign") @Max(100L, message = "Message with \\$dollarSign") dollarPropLong: Long? = null, + @QueryValue("\\$propInt") @Nullable @Min(10, message = "Message with \\$dollarSign") @Max(100, message = "Message with \\$dollarSign") dollarPropInt: Int? = null, + @QueryValue("\\$propEmail") @Nullable @Email(regexp = "poi\\\\.feedback\\\\.Review\\\\$0(.)*", message = "Message with \\$dollarSign") dollarPropEmail: String? = null, + @QueryValue("\\$propListMinMax") @Nullable @Format(FORMAT_MULTI) dollarPropListMinMax: List<@NotNull String>? = null, + @QueryValue("\\$propListMin") @Nullable @Format(FORMAT_MULTI) dollarPropListMin: List<@NotNull String>? = null, + @QueryValue("\\$propListMax") @Nullable @Format(FORMAT_MULTI) dollarPropListMax: List<@NotNull String>? = null, + @QueryValue("\\$propStrMinMax") @Nullable @Size(min = 10, max = 100, message = "Message with \\$dollarSign") dollarPropStrMinMax: String? = null, + @QueryValue("\\$propStrMin") @Nullable @Size(min = 10, message = "Message with \\$dollarSign") dollarPropStrMin: String? = null, + @QueryValue("\\$propStrMax") @Nullable @Size(max = 100, message = "Message with \\$dollarSign") dollarPropStrMax: String? = null, + @QueryValue("\\$propStrPattern") @Nullable @Pattern(regexp = "poi\\\\.feedback\\\\.Review\\\\$0(.)*", message = "Message with \\$dollarSign") dollarPropStrPattern: String? = null, + ): Mono + } + """ + ); + assertFileContains(path + "auth/config/ApiKeyAuthConfig.kt", + """ + @EachProperty("security.\\$myClientId.api-key-auth") + class ApiKeyAuthConfig @ConfigurationInject constructor( + """ + ); + assertFileContains(path + "auth/config/HttpBasicAuthConfig.kt", + """ + @EachProperty("security.\\$myClientId.basic-auth") + class HttpBasicAuthConfig @ConfigurationInject constructor( + """ + ); + assertFileContains(path + "auth/AuthorizationFilter.kt", + """ + @Filter(serviceId = ["\\$myClientId"], excludeServiceId = ["\\$notMyClientId"], patterns = [Filter.MATCH_ALL_PATTERN]) + open class AuthorizationFilter( + """ + ); + } } diff --git a/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautServerCodegenTest.java b/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautServerCodegenTest.java index 5a5120dd97..63efa3fde5 100644 --- a/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautServerCodegenTest.java +++ b/openapi-generator/src/test/java/io/micronaut/openapi/generator/KotlinMicronautServerCodegenTest.java @@ -773,13 +773,13 @@ void testCustomValidationMessages() { @QueryValue("strParam3") @NotNull @Format(FORMAT_MULTI) strParam3: List<@Pattern(regexp = "my_pattern", message = "This is string pattern message") @Size(max = 10, message = "This is min max string length message") @NotNull(message = "This is required string message") String>, """, """ - @QueryValue("intParam") @NotNull @Format(FORMAT_MULTI) intParam: List<@NotNull(message = "This is required int message") @Min(value = 5, message = "This is min message") @Max(value = 10, message = "This is max message") Int>, + @QueryValue("intParam") @NotNull @Format(FORMAT_MULTI) intParam: List<@NotNull(message = "This is required int message") @Min(5, message = "This is min message") @Max(10, message = "This is max message") Int>, """, """ - @QueryValue("decimalParam") @NotNull @Format(FORMAT_MULTI) decimalParam: List<@NotNull(message = "This is required decimal message") @DecimalMin(value = "5.5", message = "This is decimal min message") @DecimalMax(value = "10.5", message = "This is decimal max message") BigDecimal>, + @QueryValue("decimalParam") @NotNull @Format(FORMAT_MULTI) decimalParam: List<@NotNull(message = "This is required decimal message") @DecimalMin("5.5", message = "This is decimal min message") @DecimalMax("10.5", message = "This is decimal max message") BigDecimal>, """, """ - @QueryValue("decimalParam2") @NotNull(message = "This is required param message") @Format(FORMAT_MULTI) decimalParam2: List<@NotNull(message = "This is required decimal message") @DecimalMin(value = "5.5", inclusive = false, message = "This is decimal min message") @DecimalMax(value = "10.5", inclusive = false, message = "This is decimal max message") BigDecimal>, + @QueryValue("decimalParam2") @NotNull(message = "This is required param message") @Format(FORMAT_MULTI) decimalParam2: List<@NotNull(message = "This is required decimal message") @DecimalMin("5.5", inclusive = false, message = "This is decimal min message") @DecimalMax("10.5", inclusive = false, message = "This is decimal max message") BigDecimal>, """, """ @QueryValue("positiveParam") @NotNull @Format(FORMAT_MULTI) positiveParam: List<@NotNull(message = "This is required int message") @Positive(message = "This is positive message") Int>, @@ -1385,4 +1385,293 @@ fun savePublic( """ ); } + + @Test + void testDollarSign() { + + var codegen = new KotlinMicronautServerCodegen(); + String outputPath = generateFiles(codegen, "src/test/resources/3_0/dollar-sign.yml"); + + String path = outputPath + "src/main/kotlin/org/openapitools/"; + assertFileContains(path + "api/Tag1Api.kt", + """ + @Controller + @Tag(name = "\\$tag1", description = "Desc for tag with \\$dollarSign") + interface Tag1Api { + + /** + * {@summary summary with $dollarSign} + * contains $strings + * + * @param dollarPathVar desc pathVar with $dollarSign (required) + * @param schemaTitleWithDollarDollarSign Request body desc with $dollarSign (required) + * @param dollarQueryVar desc queryVar with $dollarSign (optional, default to ref2/$ref) + * Deprecated: Deprecated message with $dollarSign + * @param dollarHeaderVar desc header with $dollarSign (optional, default to $dollar) + * @param dollarCookieVar desc cookie with $dollarSign (optional, default to $dollar) + * @param dollarPropDouble (optional) + * @param dollarPropLong (optional) + * @param dollarPropInt (optional) + * @param dollarPropEmail (optional) + * @param dollarPropListMinMax (optional) + * @param dollarPropListMin (optional) + * @param dollarPropListMax (optional) + * @param dollarPropStrMinMax (optional) + * @param dollarPropStrMin (optional) + * @param dollarPropStrMax (optional) + * @param dollarPropStrPattern (optional) + * + * @return desc resp 200 with $dollarSign (status code 200) + * or desc resp 404 with $dollarSign (status code 404) + * + * @deprecated Deprecated message with $dollarSign + * + * @see summary with $dollarSign Documentation + */ + @Deprecated("Deprecated message with \\$dollarSign") + @Operation( + operationId = "getStrings", + summary = "summary with \\$dollarSign", + description = "contains \\$strings", + tags = [ "\\$tag1", "\\$tag2" ], + responses = [ + ApiResponse(responseCode = "200", description = "desc resp 200 with \\$dollarSign", content = [ + Content(mediaType = "\\$application/json", schema = Schema(implementation = String::class)), + ]), + ApiResponse(responseCode = "404", description = "desc resp 404 with \\$dollarSign", content = [ + Content(mediaType = "\\$application/json", schema = Schema(implementation = String::class)), + ]), + ], + parameters = [ + Parameter(name = "\\$pathVar", description = "desc pathVar with \\$dollarSign", required = true, `in` = ParameterIn.PATH), + Parameter(name = "\\$queryVar", deprecated = true, description = "desc queryVar with \\$dollarSign", `in` = ParameterIn.QUERY), + Parameter(name = "\\$headerVar", description = "desc header with \\$dollarSign", `in` = ParameterIn.HEADER), + Parameter(name = "\\$cookieVar", description = "desc cookie with \\$dollarSign", `in` = ParameterIn.COOKIE), + Parameter(name = "\\$propDouble", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propLong", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propInt", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propEmail", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propListMinMax", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propListMin", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propListMax", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propStrMinMax", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propStrMin", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propStrMax", `in` = ParameterIn.QUERY), + Parameter(name = "\\$propStrPattern", `in` = ParameterIn.QUERY), + ], + security = [ + SecurityRequirement(name = "\\$notSimpleAuth"), + SecurityRequirement(name = "\\$OAuth2", scopes = ["\\$read", "\\$write"]), + ], + ) + @Get("/\\$paths/{\\$pathVar}") + @Produces("\\$application/json") + @Consumes("\\$application/json") + @Secured("\\\\\\$notRead", "\\\\\\$notWrite") + fun getStrings( + @PathVariable("\\$pathVar", defaultValue = "\\$dollar") @NotNull dollarPathVar: String = "\\$dollar", + @Body @NotNull @Valid schemaTitleWithDollarDollarSign: SchemaTitleWithDollarDollarSign, + @QueryValue("\\$queryVar", defaultValue = "ref2/\\$ref") @Nullable @java.lang.Deprecated dollarQueryVar: DollarGetDollarStringsDollarQueryVarParameter? = DollarGetDollarStringsDollarQueryVarParameter.REF2__REF, + @Header("\\$headerVar", defaultValue = "\\$dollar") @Nullable dollarHeaderVar: String? = "\\$dollar", + @CookieValue("\\$cookieVar", defaultValue = "\\$dollar") @Nullable dollarCookieVar: String? = "\\$dollar", + @QueryValue("\\$propDouble") @Nullable @DecimalMin("10", message = "Message with \\$dollarSign") @DecimalMax("100", message = "Message with \\$dollarSign") dollarPropDouble: BigDecimal? = null, + @QueryValue("\\$propLong") @Nullable @Min(10L, message = "Message with \\$dollarSign") @Max(100L, message = "Message with \\$dollarSign") dollarPropLong: Long? = null, + @QueryValue("\\$propInt") @Nullable @Min(10, message = "Message with \\$dollarSign") @Max(100, message = "Message with \\$dollarSign") dollarPropInt: Int? = null, + @QueryValue("\\$propEmail") @Nullable @Email(regexp = "poi\\\\.feedback\\\\.Review\\\\$0(.)*", message = "Message with \\$dollarSign") dollarPropEmail: String? = null, + @QueryValue("\\$propListMinMax") @Nullable @Format(FORMAT_MULTI) dollarPropListMinMax: List<@NotNull String>? = null, + @QueryValue("\\$propListMin") @Nullable @Format(FORMAT_MULTI) dollarPropListMin: List<@NotNull String>? = null, + @QueryValue("\\$propListMax") @Nullable @Format(FORMAT_MULTI) dollarPropListMax: List<@NotNull String>? = null, + @QueryValue("\\$propStrMinMax") @Nullable @Size(min = 10, max = 100, message = "Message with \\$dollarSign") dollarPropStrMinMax: String? = null, + @QueryValue("\\$propStrMin") @Nullable @Size(min = 10, message = "Message with \\$dollarSign") dollarPropStrMin: String? = null, + @QueryValue("\\$propStrMax") @Nullable @Size(max = 100, message = "Message with \\$dollarSign") dollarPropStrMax: String? = null, + @QueryValue("\\$propStrPattern") @Nullable @Pattern(regexp = "poi\\\\.feedback\\\\.Review\\\\$0(.)*", message = "Message with \\$dollarSign") dollarPropStrPattern: String? = null, + ): Mono + + } + """ + ); + + assertFileContains(path + "model/DollarGetDollarStringsDollarQueryVarParameter.kt", + """ + enum class DollarGetDollarStringsDollarQueryVarParameter( + @get:JsonValue + val value: String, + ) { + + /** + * desc enumConst1 with $dollarSign + */ + @JsonProperty("ref1/\\$ref") + REF1__REF("ref1/\\$ref"), + /** + * desc enumConst2 with $dollarSign + */ + @Deprecated("") + @JsonProperty("ref2/\\$ref") + REF2__REF("ref2/\\$ref"), + ; + + override fun toString(): String = value + + companion object { + + @JvmField + val VALUE_MAPPING = entries.associateBy { it.value } + + /** + * Create this enum from a value. + * + * @param value The value + * + * @return The enum + */ + @JvmStatic + @JsonCreator + fun fromValue(value: String): DollarGetDollarStringsDollarQueryVarParameter { + require(VALUE_MAPPING.containsKey(value)) { "Unexpected value '$value'" } + return VALUE_MAPPING[value]!! + } + } + } + """ + ); + + assertFileContains(path + "model/SchemaTitleWithDollarDollarSign.kt", + """ + /** + * Schema desc with $dollarSign + */ + @Schema(description = "Schema desc with \\$dollarSign") + @Serdeable + @JsonPropertyOrder( + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP1, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_DOUBLE, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_LONG, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_INT, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_EMAIL, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_LIST_MIN_MAX, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_LIST_MIN, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_LIST_MAX, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_STR_MIN_MAX, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_STR_MIN, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_DOLLAR_PROP_STR_MAX, + SchemaTitleWithDollarDollarSign.JSON_PROPERTY_PROP2, + ) + @Generated("io.micronaut.openapi.generator.KotlinMicronautServerCodegen") + data class SchemaTitleWithDollarDollarSign( + + /** + * Schema prop1 desc with $dollarSign + * + * @deprecated Deprecated message with $dollarSign + */ + @Deprecated("Deprecated message with \\$dollarSign") + @field:NotNull(message = "Message with \\\\\\$dollarSign") + @field:Pattern(regexp = "poi\\\\.feedback\\\\.Review\\\\$0(.)*", message = "Message with \\\\\\$dollarSign") + @field:Size(min = 10, message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$prop1", example = "\\$dollarSign", description = "Schema prop1 desc with \\$dollarSign", requiredMode = Schema.RequiredMode.REQUIRED, deprecated = true) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP1) + var dollarProp1: String, + + @field:Nullable + @field:DecimalMin("10", message = "Message with \\\\\\$dollarSign") + @field:DecimalMax("100", message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propDouble", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_DOUBLE) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropDouble: BigDecimal? = null, + + @field:Nullable + @field:Min(10L, message = "Message with \\\\\\$dollarSign") + @field:Max(100L, message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propLong", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_LONG) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropLong: Long? = null, + + @field:Nullable + @field:Min(10, message = "Message with \\\\\\$dollarSign") + @field:Max(100, message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propInt", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_INT) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropInt: Int? = null, + + @field:Nullable + @field:Email(regexp = "poi\\\\.feedback\\\\.Review\\\\$0(.)*", message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propEmail", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_EMAIL) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropEmail: String? = null, + + @field:Nullable + @field:Schema(name = "\\$propListMinMax", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_LIST_MIN_MAX) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropListMinMax: List<@NotNull String>? = null, + + @field:Nullable + @field:Schema(name = "\\$propListMin", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_LIST_MIN) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropListMin: List<@NotNull String>? = null, + + @field:Nullable + @field:Schema(name = "\\$propListMax", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_LIST_MAX) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropListMax: List<@NotNull String>? = null, + + @field:Nullable + @field:Size(min = 10, max = 100, message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propStrMinMax", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_STR_MIN_MAX) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropStrMinMax: String? = null, + + @field:Nullable + @field:Size(min = 10, message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propStrMin", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_STR_MIN) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropStrMin: String? = null, + + @field:Nullable + @field:Size(max = 100, message = "Message with \\\\\\$dollarSign") + @field:Schema(name = "\\$propStrMax", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @field:JsonProperty(JSON_PROPERTY_DOLLAR_PROP_STR_MAX) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var dollarPropStrMax: String? = null, + + /** + * @deprecated Deprecated message with $dollarSign + */ + @Deprecated("Deprecated message with \\$dollarSign") + @field:Nullable + @field:Valid + @field:Schema(name = "prop2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, deprecated = true) + @field:JsonProperty(JSON_PROPERTY_PROP2) + @field:JsonInclude(JsonInclude.Include.USE_DEFAULTS) + var prop2: DollarSomeDto? = null, + ) { + + companion object { + + const val JSON_PROPERTY_DOLLAR_PROP1 = "\\$prop1" + const val JSON_PROPERTY_DOLLAR_PROP_DOUBLE = "\\$propDouble" + const val JSON_PROPERTY_DOLLAR_PROP_LONG = "\\$propLong" + const val JSON_PROPERTY_DOLLAR_PROP_INT = "\\$propInt" + const val JSON_PROPERTY_DOLLAR_PROP_EMAIL = "\\$propEmail" + const val JSON_PROPERTY_DOLLAR_PROP_LIST_MIN_MAX = "\\$propListMinMax" + const val JSON_PROPERTY_DOLLAR_PROP_LIST_MIN = "\\$propListMin" + const val JSON_PROPERTY_DOLLAR_PROP_LIST_MAX = "\\$propListMax" + const val JSON_PROPERTY_DOLLAR_PROP_STR_MIN_MAX = "\\$propStrMinMax" + const val JSON_PROPERTY_DOLLAR_PROP_STR_MIN = "\\$propStrMin" + const val JSON_PROPERTY_DOLLAR_PROP_STR_MAX = "\\$propStrMax" + const val JSON_PROPERTY_PROP2 = "prop2" + } + } + """ + ); + } } diff --git a/openapi-generator/src/test/resources/3_0/dollar-sign.yml b/openapi-generator/src/test/resources/3_0/dollar-sign.yml new file mode 100644 index 0000000000..21c285dd42 --- /dev/null +++ b/openapi-generator/src/test/resources/3_0/dollar-sign.yml @@ -0,0 +1,318 @@ +openapi: 3.0.0 +info: + version: $1.0.0 + title: Tittle with $dollarSign + description: API desc with $dollarSign + contact: + name: Name with $dollarSign + email: email$@withDollar.com + url: https://some.server.com/$dollar-sign + license: + name: Name with $dollarSign + url: https://some.another.server.com/$dollar-sign +tags: + - name: $tag1 + description: Desc for tag with $dollarSign + - name: $tag2 + description: Desc for tag with $dollarSign2 +externalDocs: + description: Desc with $dollarSign + url: https://external.server.com/$dollar-sign +security: + - simpleAuth: [ $read, $write ] + - $notSimpleAuth: [ $notRead, $notWrite ] +servers: + - url: https://localhost:8000/api/$/$sign + description: Api server desc with $dollarSign + variables: + API_$VERSION: + description: Api API_$VERSION desc with $dollarSign + enum: + - $v1 + - $v2 + - $v3 + - $v4 + - $v5 + - $v6 + - $v7 + default: $v6 +paths: + /$paths/{$pathVar}: + get: + operationId: $get$Strings + description: contains $strings + summary: summary with $dollarSign + deprecated: true + x-deprecated-message: Deprecated message with $dollarSign + security: + - $notSimpleAuth: [ $notRead, $notWrite ] + - $OAuth2: [ $read, $write ] + externalDocs: + url: https://external2.server.com/$dollar-sign + tags: + - $tag1 + - $tag2 + servers: + - url: https://localhost:9090/api/$/$sign + description: Another api server desc with $dollarSign + variables: + API_NOT_$VERSION: + description: Api API_NOT_$VERSION desc with $dollarSign + enum: + - $v1 + - $v2 + default: $v1 + parameters: + - name: $queryVar + in: query + description: desc queryVar with $dollarSign + required: false + deprecated: true + x-deprecated-message: Deprecated message with $dollarSign + schema: + type: string + default: ref2/$ref + enum: + - ref1/$ref + - ref2/$ref + x-enum-descriptions: + - desc enumConst1 with $dollarSign + - desc enumConst2 with $dollarSign + x-deprecated: + - ref2/$ref + - name: $pathVar + in: path + description: desc pathVar with $dollarSign + required: true + schema: + type: string + default: $dollar + - name: $headerVar + in: header + description: desc header with $dollarSign + required: false + schema: + type: string + default: $dollar + - name: $cookieVar + in: cookie + description: desc cookie with $dollarSign + required: false + schema: + type: string + default: $dollar + - name: $propDouble + in: query + schema: + type: number + minimum: 10 + maximum: 100 + x-minimum-message: Message with $dollarSign + x-maximum-message: Message with $dollarSign + - name: $propLong + in: query + schema: + type: integer + format: int64 + minimum: 10 + maximum: 100 + x-minimum-message: Message with $dollarSign + x-maximum-message: Message with $dollarSign + - name: $propInt + in: query + schema: + type: integer + format: int32 + minimum: 10 + maximum: 100 + x-minimum-message: Message with $dollarSign + x-maximum-message: Message with $dollarSign + - name: $propEmail + in: query + schema: + type: string + format: email + pattern: poi\.feedback\.Review\$0(.)* + x-pattern-message: Message with $dollarSign + - name: $propListMinMax + in: query + schema: + type: array + minLength: 10 + maxLength: 100 + x-size-message: Message with $dollarSign + items: + type: string + - name: $propListMin + in: query + schema: + type: array + maxLength: 100 + x-size-message: Message with $dollarSign + items: + type: string + - name: $propListMax + in: query + schema: + type: array + maxLength: 100 + x-size-message: Message with $dollarSign + items: + type: string + - name: $propStrMinMax + in: query + schema: + type: string + minLength: 10 + maxLength: 100 + x-size-message: Message with $dollarSign + - name: $propStrMin + in: query + schema: + type: string + minLength: 10 + x-size-message: Message with $dollarSign + - name: $propStrMax + in: query + schema: + type: string + maxLength: 100 + x-size-message: Message with $dollarSign + - name: $propStrPattern + in: query + schema: + type: string + pattern: poi\.feedback\.Review\$0(.)* + x-pattern-message: Message with $dollarSign + requestBody: + description: Request body desc with $dollarSign + required: true + content: + $application/json: + schema: + type: object + title: Schema title with $dollarSign + description: Schema desc with $dollarSign + externalDocs: + url: https://external2.server.com/$dollar-sign + required: + - $prop1 + properties: + $propDouble: + type: number + minimum: 10 + maximum: 100 + x-minimum-message: Message with $dollarSign + x-maximum-message: Message with $dollarSign + $propLong: + type: integer + format: int64 + minimum: 10 + maximum: 100 + x-minimum-message: Message with $dollarSign + x-maximum-message: Message with $dollarSign + $propInt: + type: integer + format: int32 + minimum: 10 + maximum: 100 + x-minimum-message: Message with $dollarSign + x-maximum-message: Message with $dollarSign + $propEmail: + type: string + format: email + pattern: poi\.feedback\.Review\$0(.)* + x-pattern-message: Message with $dollarSign + $propListMinMax: + type: array + minLength: 10 + maxLength: 100 + x-size-message: Message with $dollarSign + items: + type: string + $propListMin: + type: array + maxLength: 100 + x-size-message: Message with $dollarSign + items: + type: string + $propListMax: + type: array + maxLength: 100 + x-size-message: Message with $dollarSign + items: + type: string + $propStrMinMax: + type: string + minLength: 10 + maxLength: 100 + x-size-message: Message with $dollarSign + $propStrMin: + type: string + minLength: 10 + x-size-message: Message with $dollarSign + $propStrMax: + type: string + maxLength: 100 + x-size-message: Message with $dollarSign + $prop1: + type: string + title: Schema prop1 title with $dollarSign + description: Schema prop1 desc with $dollarSign + example: $dollarSign + deprecated: true + pattern: poi\.feedback\.Review\$0(.)* + nullable: false + minLength: 10 + x-not-null-message: Message with $dollarSign + x-pattern-message: Message with $dollarSign + x-size-message: Message with $dollarSign + x-deprecated-message: Deprecated message with $dollarSign + prop2: + $ref: '#/components/schemas/$SomeDto' + responses: + "200": + description: desc resp 200 with $dollarSign + content: + $application/json: + schema: + type: string + description: Content desc resp with $dollarSign + "404": + description: desc resp 404 with $dollarSign + content: + $application/json: + schema: + type: string + description: Content desc resp with $dollarSign +components: + schemas: + $SomeDto: + type: object + title: Schema title with $dollarSign + description: Schema desc with $dollarSign + deprecated: true + x-deprecated-message: Deprecated message with $dollarSign + properties: + $prop1: + type: string + title: Schema prop1 title with $dollarSign + description: Schema prop1 desc with $dollarSign + securitySchemes: + simpleAuth: + type: http + scheme: bearer + bearerFormat: JWT + $notSimpleAuth: + scheme: basic + type: http + $OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: https://example.com/oauth/authorize + tokenUrl: https://example.com/oauth/token + scopes: + $read: Grants $read access + $write: Grants $write access + $admin: Grants $access to admin operations