Skip to content

Commit 6425283

Browse files
authored
Merge pull request #265 from swagger-api/add_validation_issue_8772
add validation extension
2 parents 3e35161 + d52384b commit 6425283

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import java.util.Map;
99

10+
import static io.swagger.codegen.v3.CodegenConstants.HAS_VALIDATION_EXT_NAME;
11+
1012
public class OpenAPIUtil {
1113

1214
private OpenAPI openAPI;
@@ -27,6 +29,9 @@ public void addPropertiesFromRef(Schema refSchema, CodegenProperty codegenProper
2729
codegenProperty.pattern = schema.getPattern();
2830
codegenProperty.minLength = schema.getMinLength();
2931
codegenProperty.maxLength = schema.getMaxLength();
32+
if (codegenProperty.pattern != null || codegenProperty.minLength != null || codegenProperty.maxLength != null) {
33+
codegenProperty.getVendorExtensions().put(HAS_VALIDATION_EXT_NAME, Boolean.TRUE);
34+
}
3035
}
3136

3237
public static String getSimpleRef(String ref) {

0 commit comments

Comments
 (0)