We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex string is not escaped when a property refers to a schema https://github.com/swagger-api/swagger-codegen-generators/blob/master/src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java#L25-L27
public static void addPropertiesFromRef(OpenAPI openAPI, Schema refSchema, CodegenProperty codegenProperty) { final Map<String, Schema> allSchemas = openAPI.getComponents().getSchemas(); if (allSchemas == null || allSchemas.isEmpty()) { return; } final Schema schema = allSchemas.get(getSimpleRef(refSchema.get$ref())); if (schema == null) { return; } if (StringUtils.isBlank(codegenProperty.pattern)) { // pattern here is not escaped codegenProperty.pattern = schema.getPattern(); } codegenProperty.minLength = schema.getMinLength(); codegenProperty.maxLength = schema.getMaxLength(); if (codegenProperty.pattern != null || codegenProperty.minLength != null || codegenProperty.maxLength != null) { codegenProperty.getVendorExtensions().put(HAS_VALIDATION_EXT_NAME, Boolean.TRUE); } }
Potential fix
public static void addPropertiesFromRef(CodegenConfig codegenConfig, OpenAPI openAPI, Schema refSchema, CodegenProperty codegenProperty) { final Map<String, Schema> allSchemas = openAPI.getComponents().getSchemas(); if (allSchemas == null || allSchemas.isEmpty()) { return; } final Schema schema = allSchemas.get(getSimpleRef(refSchema.get$ref())); if (schema == null) { return; } if (StringUtils.isBlank(codegenProperty.pattern)) { // use toRegularExpression method in CodegenConfig to escape codegenProperty.pattern = codegenConfig.toRegularExpression(schema.getPattern()); } codegenProperty.minLength = schema.getMinLength(); codegenProperty.maxLength = schema.getMaxLength(); if (codegenProperty.pattern != null || codegenProperty.minLength != null || codegenProperty.maxLength != null) { codegenProperty.getVendorExtensions().put(HAS_VALIDATION_EXT_NAME, Boolean.TRUE); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Regex string is not escaped when a property refers to a schema
https://github.com/swagger-api/swagger-codegen-generators/blob/master/src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java#L25-L27
Potential fix
The text was updated successfully, but these errors were encountered: