Java Code Examples for io.swagger.v3.oas.models.media.Schema#getMaxLength()
The following examples show how to use
io.swagger.v3.oas.models.media.Schema#getMaxLength() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenApiClientGenerator.java From spring-openapi with MIT License | 5 votes |
private FieldSpec.Builder getStringBasedSchemaField(String fieldName, Schema innerSchema, TypeSpec.Builder typeSpecBuilder) { if (innerSchema.getFormat() == null) { ClassName stringClassName = ClassName.get(JAVA_LANG_PKG, "String"); FieldSpec.Builder fieldBuilder = FieldSpec.builder(stringClassName, fieldName, Modifier.PRIVATE); if (innerSchema.getPattern() != null) { fieldBuilder.addAnnotation(AnnotationSpec.builder(Pattern.class) .addMember("regexp", "$S", innerSchema.getPattern()) .build() ); } if (innerSchema.getMinLength() != null || innerSchema.getMaxLength() != null) { AnnotationSpec.Builder sizeAnnotationBuilder = AnnotationSpec.builder(Size.class); if (innerSchema.getMinLength() != null) { sizeAnnotationBuilder.addMember("min", "$L", innerSchema.getMinLength()); } if (innerSchema.getMaxLength() != null) { sizeAnnotationBuilder.addMember("max", "$L", innerSchema.getMaxLength()); } fieldBuilder.addAnnotation(sizeAnnotationBuilder.build()); } enrichWithGetSet(typeSpecBuilder, stringClassName, fieldName); return fieldBuilder; } else if (equalsIgnoreCase(innerSchema.getFormat(), "date")) { ClassName localDateClassName = ClassName.get(JAVA_TIME_PKG, "LocalDate"); enrichWithGetSet(typeSpecBuilder, localDateClassName, fieldName); return FieldSpec.builder(localDateClassName, fieldName, Modifier.PRIVATE); } else if (equalsIgnoreCase(innerSchema.getFormat(), "date-time")) { ClassName localDateTimeClassName = ClassName.get(JAVA_TIME_PKG, "LocalDateTime"); enrichWithGetSet(typeSpecBuilder, localDateTimeClassName, fieldName); return FieldSpec.builder(localDateTimeClassName, fieldName, Modifier.PRIVATE); } throw new IllegalArgumentException(String.format("Error parsing string based property [%s]", fieldName)); }
Example 2
Source File: SchemaMaxLengthChangeInRequestValidator.java From servicecomb-toolkit with Apache License 2.0 | 4 votes |
@Override protected Integer getProperty(Schema schema) { return schema.getMaxLength(); }
Example 3
Source File: SchemaMaxLengthChangeInResponseValidator.java From servicecomb-toolkit with Apache License 2.0 | 4 votes |
@Override protected Integer getProperty(Schema schema) { return schema.getMaxLength(); }
Example 4
Source File: OASMergeUtil.java From crnk-framework with Apache License 2.0 | 4 votes |
public static Schema mergeSchema(Schema thisSchema, Schema thatSchema) { if (thatSchema == null) { return thisSchema; } // Overwriting `implementation` is explicitly disallowed // Overwriting `not` is explicitly disallowed // Overwriting `oneOf` is explicitly disallowed // Overwriting `anyOf` is explicitly disallowed // Overwriting `allOf` is explicitly disallowed // Overwriting `name` is explicitly disallowed if (thatSchema.getTitle() != null) { thisSchema.setTitle(thatSchema.getTitle()); } // Overwriting `multipleOf` is explicitly disallowed if (thatSchema.getMaximum() != null) { thisSchema.setMaximum(thatSchema.getMaximum()); } if (thatSchema.getExclusiveMaximum() != null) { thisSchema.setExclusiveMaximum(thatSchema.getExclusiveMaximum()); } if (thatSchema.getMinimum() != null) { thisSchema.setMinimum(thatSchema.getMinimum()); } if (thatSchema.getExclusiveMinimum() != null) { thisSchema.setExclusiveMinimum(thatSchema.getExclusiveMinimum()); } if (thatSchema.getMaxLength() != null) { thisSchema.setMaxLength(thatSchema.getMaxLength()); } if (thatSchema.getMinLength() != null) { thisSchema.setMinLength(thatSchema.getMinLength()); } if (thatSchema.getPattern() != null) { thisSchema.setPattern(thatSchema.getPattern()); } if (thatSchema.getMaxProperties() != null) { thisSchema.setMaxProperties(thatSchema.getMaxProperties()); } if (thatSchema.getMinProperties() != null) { thisSchema.setMinProperties(thatSchema.getMinProperties()); } // RequiredProperties if (thatSchema.getRequired() != null) { thisSchema.setRequired(thatSchema.getRequired()); } // Overwriting `name` is explicitly disallowed if (thatSchema.getDescription() != null) { thisSchema.setDescription(thatSchema.getDescription()); } if (thatSchema.getFormat() != null) { thisSchema.setFormat(thatSchema.getFormat()); } // Overwriting `ref` is explicitly disallowed if (thatSchema.getNullable() != null) { thisSchema.setNullable(thatSchema.getNullable()); } // Overwriting `AccessMode` is explicitly disallowed if (thatSchema.getExample() != null) { thisSchema.setExample(thatSchema.getExample()); } if (thatSchema.getExternalDocs() != null) { thisSchema.setExternalDocs(thatSchema.getExternalDocs()); } if (thatSchema.getDeprecated() != null) { thisSchema.setDeprecated(thatSchema.getDeprecated()); } if (thatSchema.getType() != null) { thisSchema.setType(thatSchema.getType()); } if (thatSchema.getEnum() != null) { thisSchema.setEnum(thatSchema.getEnum()); } if (thatSchema.getDefault() != null) { thisSchema.setDefault(thatSchema.getDefault()); } // Overwriting `discriminator` is explicitly disallowed // Overwriting `hidden` is explicitly disallowed // Overwriting `subTypes` is explicitly disallowed if (thatSchema.getExtensions() != null) { thisSchema.setExtensions(thatSchema.getExtensions()); } return thisSchema; }