com.fasterxml.jackson.module.jsonSchema.JsonSchema Java Examples
The following examples show how to use
com.fasterxml.jackson.module.jsonSchema.JsonSchema.
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: HttpRequestWrapperProcessorTest.java From syndesis with Apache License 2.0 | 6 votes |
@Test public void shouldMapValuesFromHttpRequest() throws Exception { final String schemaStr = JsonUtils.writer().forType(JsonSchema.class).writeValueAsString(schema); final JsonNode schemaNode = JsonUtils.reader().forType(JsonNode.class).readTree(schemaStr); final HttpRequestWrapperProcessor processor = new HttpRequestWrapperProcessor(schemaNode); final Exchange exchange = mock(Exchange.class); final Message message = mock(Message.class); final ExtendedCamelContext camelContext = mock(ExtendedCamelContext.class); when(camelContext.adapt(ExtendedCamelContext.class)).thenReturn(camelContext); when(camelContext.getHeadersMapFactory()).thenReturn(mock(HeadersMapFactory.class)); when(exchange.getIn()).thenReturn(message); when(exchange.getContext()).thenReturn(camelContext); final HttpServletRequest servletRequest = mock(HttpServletRequest.class); when(message.getHeader(Exchange.HTTP_SERVLET_REQUEST, HttpServletRequest.class)).thenReturn(servletRequest); when(message.getBody()).thenReturn(givenBody); when(servletRequest.getParameterValues("param1")).thenReturn(new String[] {"param_value1"}); when(servletRequest.getParameterValues("param2")).thenReturn(new String[] {"param_value2_1", "param_value2_2"}); processor.process(exchange); final ArgumentCaptor<Message> replacement = ArgumentCaptor.forClass(Message.class); verify(exchange).setIn(replacement.capture()); assertThat(replacement.getValue().getBody()).isEqualTo(replacedBody); }
Example #2
Source File: Doc.java From dremio-oss with Apache License 2.0 | 6 votes |
private void arrayExample(StringBuilder sb, int maxlength, String indent, JsonSchema schema, Map<String, JsonSchema> refs, Set<String> followed, Set<String> referenced) { sb.append("[\n").append(indent).append(" "); ArraySchema as = schema.asArraySchema(); if (as.getItems() == null) { sb.append(" ... ]"); } else if (as.getItems().isSingleItems()) { example(sb, maxlength, indent + " ", as.getItems().asSingleItems().getSchema(), refs, followed, referenced); sb.append(",\n").append(indent).append(" ...\n").append(indent).append("]"); } else if (as.getItems().isArrayItems()) { ArrayItems items = as.getItems().asArrayItems(); for (JsonSchema item : items.getJsonSchemas()) { sb.append("\n").append(indent); example(sb, maxlength, indent + " ", item, refs, followed, referenced); sb.append(","); } sb.append("]"); } else { throw new UnsupportedOperationException(as.getItems().toString()); } }
Example #3
Source File: GoogleSheetsMetaDataHelper.java From syndesis with Apache License 2.0 | 6 votes |
public static JsonSchema createSchema(String range, String majorDimension, boolean split, String ... columnNames) { ObjectSchema spec = new ObjectSchema(); spec.setTitle("VALUE_RANGE"); spec.putProperty("spreadsheetId", new JsonSchemaFactory().stringSchema()); RangeCoordinate coordinate = RangeCoordinate.fromRange(range); if (ObjectHelper.equal(RangeCoordinate.DIMENSION_ROWS, majorDimension)) { createSchemaFromRowDimension(spec, coordinate, columnNames); } else if (ObjectHelper.equal(RangeCoordinate.DIMENSION_COLUMNS, majorDimension)) { createSchemaFromColumnDimension(spec, coordinate); } if (split) { spec.set$schema(JSON_SCHEMA_ORG_SCHEMA); return spec; } else { ArraySchema arraySpec = new ArraySchema(); arraySpec.set$schema(JSON_SCHEMA_ORG_SCHEMA); arraySpec.setItemsSchema(spec); return arraySpec; } }
Example #4
Source File: Doc.java From dremio-oss with Apache License 2.0 | 6 votes |
private void findRefs(JsonSchema schema, Map<String, JsonSchema> refs, Set<String> referenced) { addRef(schema, refs); if (schema instanceof ReferenceSchema) { referenced.add(schema.get$ref()); } else if (schema.isArraySchema()) { ArraySchema as = schema.asArraySchema(); if (as.getItems() != null) { if (as.getItems().isSingleItems()) { findRefs(as.getItems().asSingleItems().getSchema(), refs, referenced); } else if (as.getItems().isArrayItems()) { ArrayItems items = as.getItems().asArrayItems(); for (JsonSchema item : items.getJsonSchemas()) { findRefs(item, refs, referenced); } } else { throw new UnsupportedOperationException(as.getItems().toString()); } } } else if (schema.isObjectSchema()) { ObjectSchema os = schema.asObjectSchema(); for (JsonSchema value : os.getProperties().values()) { findRefs(value, refs, referenced); } } }
Example #5
Source File: JsonSchemaInspector.java From syndesis with Apache License 2.0 | 6 votes |
static void fetchPaths(final String context, final List<String> paths, final Map<String, JsonSchema> properties) { for (final Map.Entry<String, JsonSchema> entry : properties.entrySet()) { final JsonSchema subschema = entry.getValue(); String path; final String key = entry.getKey(); if (context == null) { path = key; } else { path = context + "." + key; } if (subschema.isValueTypeSchema()) { paths.add(path); } else if (subschema.isObjectSchema()) { fetchPaths(path, paths, subschema.asObjectSchema().getProperties()); } else if (subschema.isArraySchema()) { COLLECTION_PATHS.stream().map(p -> path + "." + p).forEach(paths::add); ObjectSchema itemSchema = getItemSchema(subschema.asArraySchema()); if (itemSchema != null) { fetchPaths(path + ARRAY_CONTEXT, paths, itemSchema.getProperties()); } } } }
Example #6
Source File: AggregateMetadataHandler.java From syndesis with Apache License 2.0 | 6 votes |
/** * Converts unified Json body specification. Unified Json schema specifications hold * the actual body specification in a property. This method converts this body specification * from array to single element if necessary. */ private static String adaptUnifiedJsonBodySpecToSingleElement(String specification) throws IOException { JsonSchema schema = JsonSchemaUtils.reader().readValue(specification); if (schema.isObjectSchema()) { JsonSchema bodySchema = schema.asObjectSchema().getProperties().get(BODY); if (bodySchema != null && bodySchema.isArraySchema()) { ArraySchema.Items items = bodySchema.asArraySchema().getItems(); if (items.isSingleItems()) { schema.asObjectSchema().getProperties().put(BODY, items.asSingleItems().getSchema()); return JsonUtils.writer().writeValueAsString(schema); } } } return specification; }
Example #7
Source File: AggregateMetadataHandler.java From syndesis with Apache License 2.0 | 6 votes |
/** * Converts unified Json body specification. Unified Json schema specifications hold * the actual body specification in a property. This method converts this body specification * from single element to collection if necessary. */ private static String adaptUnifiedJsonBodySpecToCollection(String specification) throws IOException { JsonSchema schema = JsonSchemaUtils.reader().readValue(specification); if (schema.isObjectSchema()) { JsonSchema bodySchema = schema.asObjectSchema().getProperties().get(BODY); if (bodySchema != null && bodySchema.isObjectSchema()) { ArraySchema arraySchema = new ArraySchema(); arraySchema.set$schema(JSON_SCHEMA_ORG_SCHEMA); arraySchema.setItemsSchema(bodySchema); schema.asObjectSchema().getProperties().put(BODY, arraySchema); return JsonUtils.writer().writeValueAsString(schema); } } return specification; }
Example #8
Source File: SplitMetadataHandler.java From syndesis with Apache License 2.0 | 6 votes |
/** * Extract unified Json body specification from data shape specification. Unified Json schema specifications hold * the actual body specification in a property. This method extracts this property as new body specification. */ private static String extractUnifiedJsonBodySpec(String specification) throws IOException { JsonSchema schema = JsonSchemaUtils.reader().readValue(specification); if (schema.isObjectSchema()) { JsonSchema bodySchema = schema.asObjectSchema().getProperties().get("body"); if (bodySchema != null) { if (bodySchema.isArraySchema()) { ArraySchema.Items items = bodySchema.asArraySchema().getItems(); if (items.isSingleItems()) { JsonSchema itemSchema = items.asSingleItems().getSchema(); itemSchema.set$schema(schema.get$schema()); return JsonUtils.writer().writeValueAsString(itemSchema); } } else { return JsonUtils.writer().writeValueAsString(bodySchema); } } } return specification; }
Example #9
Source File: JSONSchema.java From pulsar with Apache License 2.0 | 6 votes |
/** * Implemented for backwards compatibility reasons * since the original schema generated by JSONSchema was based off the json schema standard * since then we have standardized on Avro * * @return */ public SchemaInfo getBackwardsCompatibleJsonSchemaInfo() { SchemaInfo backwardsCompatibleSchemaInfo; try { ObjectMapper objectMapper = new ObjectMapper(); JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(objectMapper); JsonSchema jsonBackwardsCompatibleSchema = schemaGen.generateSchema(pojo); backwardsCompatibleSchemaInfo = new SchemaInfo(); backwardsCompatibleSchemaInfo.setName(""); backwardsCompatibleSchemaInfo.setProperties(schemaInfo.getProperties()); backwardsCompatibleSchemaInfo.setType(SchemaType.JSON); backwardsCompatibleSchemaInfo.setSchema(objectMapper.writeValueAsBytes(jsonBackwardsCompatibleSchema)); } catch (JsonProcessingException ex) { throw new RuntimeException(ex); } return backwardsCompatibleSchemaInfo; }
Example #10
Source File: ODataMetaDataRetrievalTest.java From syndesis with Apache License 2.0 | 6 votes |
private static void checkTestServerSchemaMap(Map<String, JsonSchema> schemaMap) { JsonSchema descSchema = schemaMap.get("Description"); JsonSchema specSchema = schemaMap.get("Specification"); assertNotNull(descSchema); assertNotNull(schemaMap.get("ID")); assertNotNull(schemaMap.get("Name")); assertNotNull(specSchema); JsonFormatTypes descType = descSchema.getType(); assertNotNull(descType); assertEquals(JsonFormatTypes.STRING, descType); assertEquals(false, descSchema.getRequired()); JsonFormatTypes specType = specSchema.getType(); assertNotNull(specType); assertEquals(JsonFormatTypes.OBJECT, specType); assertEquals(false, specSchema.getRequired()); assertThat(specSchema).isInstanceOf(ObjectSchema.class); ObjectSchema specObjSchema = specSchema.asObjectSchema(); assertEquals(4, specObjSchema.getProperties().size()); }
Example #11
Source File: ODataMetaDataRetrievalTest.java From syndesis with Apache License 2.0 | 6 votes |
private static Map<String, JsonSchema> checkShape(DataShape dataShape, Class<? extends ContainerTypeSchema> expectedShapeClass) throws IOException, JsonParseException, JsonMappingException { assertNotNull(dataShape); assertEquals(DataShapeKinds.JSON_SCHEMA, dataShape.getKind()); assertNotNull(dataShape.getSpecification()); ContainerTypeSchema schema = JsonUtils.copyObjectMapperConfiguration().readValue( dataShape.getSpecification(), expectedShapeClass); Map<String, JsonSchema> propSchemaMap = null; if (schema instanceof ArraySchema) { propSchemaMap = ((ArraySchema) schema).getItems().asSingleItems().getSchema().asObjectSchema().getProperties(); } else if (schema instanceof ObjectSchema) { propSchemaMap = ((ObjectSchema) schema).getProperties(); } assertNotNull(propSchemaMap); return propSchemaMap; }
Example #12
Source File: JsonSchemaUtils.java From syndesis with Apache License 2.0 | 6 votes |
/** * This method creates a copy of the default ObjectMapper configuration and adds special Json schema compatibility handlers * for supporting draft-03, draft-04 and draft-06 level at the same time. * * Auto converts "$id" to "id" property for draft-04 compatibility. * * In case the provided schema specification to read uses draft-04 and draft-06 specific features such as "examples" or a list of "required" * properties as array these information is more or less lost and auto converted to draft-03 compatible defaults. This way we can * read the specification to draft-03 compatible objects and use those. * @return duplicated ObjectR */ public static ObjectReader reader() { return JsonUtils.copyObjectMapperConfiguration() .addHandler(new DeserializationProblemHandler() { @Override public Object handleUnexpectedToken(DeserializationContext ctxt, Class<?> targetType, JsonToken t, JsonParser p, String failureMsg) throws IOException { if (t == JsonToken.START_ARRAY && targetType.equals(Boolean.class)) { // handle Json schema draft-04 array type for required field and resolve to default value (required=true). String[] requiredProps = new StringArrayDeserializer().deserialize(p, ctxt); LOG.warn("Auto convert Json schema draft-04 \"required\" array value '{}' to default \"required=false\" value for draft-03 parser compatibility reasons", Arrays.toString(requiredProps)); return null; } return super.handleUnexpectedToken(ctxt, ctxt.constructType(targetType), t, p, failureMsg); } }) .addMixIn(JsonSchema.class, MixIn.Draft6.class) .reader() .forType(JsonSchema.class); }
Example #13
Source File: TextFieldSchemaDecorator.java From sf-java-ui with MIT License | 6 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { TextField annotation = property.getAnnotation(TextField.class); if (annotation != null) { if (annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } if (annotation.pattern() != null) { ((StringSchema) jsonschema).setPattern(annotation.pattern()); } if (annotation.minLenght() != 0) { ((StringSchema) jsonschema).setMinLength(annotation.minLenght()); } if (annotation.maxLenght() != Integer.MAX_VALUE) { ((StringSchema) jsonschema).setMaxLength(annotation.maxLenght()); } } }
Example #14
Source File: Doc.java From dremio-oss with Apache License 2.0 | 6 votes |
private void objectExample(StringBuilder sb, int maxlength, String indent, JsonSchema schema, Map<String, JsonSchema> refs, Set<String> followed, Set<String> referenced, String id) { sb.append("{"); if (referenced.contains(id)) { shortId(sb, schema); } ObjectSchema os = schema.asObjectSchema(); if (os.getProperties().isEmpty()) { AdditionalProperties additionalProperties = os.getAdditionalProperties(); if (additionalProperties instanceof SchemaAdditionalProperties) { sb.append("\n").append(indent).append(" ").append("abc").append(": "); example(sb, maxlength, indent + " ", ((SchemaAdditionalProperties) additionalProperties).getJsonSchema(), refs, followed, referenced); sb.append(", ..."); } } Map<String, JsonSchema> props = new TreeMap<>(os.getProperties()); for (Entry<String, JsonSchema> entry : props.entrySet()) { sb.append("\n").append(indent).append(" ").append(entry.getKey()).append(": "); example(sb, maxlength, indent + " ", entry.getValue(), refs, followed, referenced); sb.append(","); } sb.append("\n").append(indent).append("}"); }
Example #15
Source File: HttpRequestWrapperProcessorTest.java From syndesis with Apache License 2.0 | 6 votes |
@Test public void shouldMapValuesFromMessageHeaders() throws Exception { String schemaStr = JsonUtils.writer().forType(JsonSchema.class).writeValueAsString(schema); JsonNode schemaNode = JsonUtils.reader().forType(JsonNode.class).readTree(schemaStr); final HttpRequestWrapperProcessor processor = new HttpRequestWrapperProcessor(schemaNode); final Exchange exchange = mock(Exchange.class); final Message message = mock(Message.class); final ExtendedCamelContext camelContext = mock(ExtendedCamelContext.class); when(camelContext.adapt(ExtendedCamelContext.class)).thenReturn(camelContext); when(camelContext.getHeadersMapFactory()).thenReturn(mock(HeadersMapFactory.class)); when(exchange.getIn()).thenReturn(message); when(exchange.getContext()).thenReturn(camelContext); when(message.getBody()).thenReturn(givenBody); when(message.getHeader("param1", String[].class)).thenReturn(new String[] {"param_value1"}); when(message.getHeader("param2", String[].class)).thenReturn(new String[] {"param_value2_1", "param_value2_2"}); processor.process(exchange); final ArgumentCaptor<Message> replacement = ArgumentCaptor.forClass(Message.class); verify(exchange).setIn(replacement.capture()); assertThat(replacement.getValue().getBody()).isEqualTo(replacedBody); }
Example #16
Source File: PasswordSchemaDecorator.java From sf-java-ui with MIT License | 6 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { Optional.ofNullable(property.getAnnotation(Password.class)).ifPresent(annotation -> { if (annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } if (annotation.pattern() != null) { ((StringSchema) jsonschema).setPattern(annotation.pattern()); } if (annotation.minLenght() != 0) { ((StringSchema) jsonschema).setMinLength(annotation.minLenght()); } if (annotation.maxLenght() != Integer.MAX_VALUE) { ((StringSchema) jsonschema).setMaxLength(annotation.maxLenght()); } }); }
Example #17
Source File: MetadataResourceTest.java From alchemy with MIT License | 6 votes |
@Test public void testGetIdentitySchema() { get(METADATA_IDENTITY_TYPE_SCHEMA_ENDPOINT, "foobar") .assertStatus(Status.NOT_FOUND); final JsonSchema schema = get(METADATA_IDENTITY_TYPE_SCHEMA_ENDPOINT, "user") .assertStatus(Status.OK) .result(JsonSchema.class); assertNotNull(schema); assertTrue( schema .asObjectSchema() .getProperties() .get("name") .isStringSchema() ); }
Example #18
Source File: JsonSchemaUtil.java From mPass with Apache License 2.0 | 6 votes |
/** 根据schema转换 */ private static Object convertArrayItem(Object src, Items items, boolean checkReadOnly, boolean ignoreException, String path) { if (src == null) { return null; } if (items.isSingleItems()) { JsonSchema schema = items.asSingleItems().getSchema(); if (schema == null) { return src; } return convert(src, schema, checkReadOnly, ignoreException, path); } else if (items.isArrayItems()) { return src; } else { return src; } }
Example #19
Source File: JsonSchemaUtil.java From mPass with Apache License 2.0 | 6 votes |
/** 根据schema转换 */ public static Object convert(Object src, JsonSchema schema, boolean checkReadOnly, boolean ignoreException, String path) { if (src == null) { return null; } if (schema.isArraySchema()) { return convertArray(src, schema.asArraySchema(), checkReadOnly, ignoreException, path); } else if (schema.isObjectSchema()) { return convertObject(src, schema.asObjectSchema(), checkReadOnly, ignoreException, path); } else if (schema.isBooleanSchema()) { return TypeUtil.cast(src, Boolean.class); } else if (schema.isIntegerSchema()) { return TypeUtil.cast(src, Long.class); } else if (schema.isNumberSchema()) { return TypeUtil.cast(src, Double.class); } else if (schema.isStringSchema()) { return TypeUtil.cast(src, String.class); } else if (schema.isNullSchema()) { return null; } else { return src; } }
Example #20
Source File: JsonSchemaUtil.java From mPass with Apache License 2.0 | 6 votes |
/** 完善JsonSchema信息 */ private static void completeJsonSchema(JsonSchema schema, MetaProperty property) { schema.setDescription(property.getLabel()); if (property.isReadOnly()) { schema.setReadonly(true); } if (property.isNotNull()) { schema.setRequired(true); } if (MetaConstant.isEnum(property) && schema instanceof ValueTypeSchema) { Set<String> enums = new HashSet<>(); for (EnumItem item : property.getEnumList()) { enums.add(item.getValue()); } ((ValueTypeSchema) schema).setEnums(enums); } }
Example #21
Source File: SalesforceMetadataRetrievalTest.java From syndesis with Apache License 2.0 | 6 votes |
public SalesforceMetadataRetrievalTest() { final Map<String, JsonSchema> objectProperties = new HashMap<>(); objectProperties.put("simpleProperty", new StringSchema()); objectProperties.put("anotherProperty", new NumberSchema()); final StringSchema uniqueProperty1 = new StringSchema(); uniqueProperty1.setDescription("idLookup,autoNumber"); uniqueProperty1.setTitle("Unique property 1"); final StringSchema uniqueProperty2 = new StringSchema(); uniqueProperty2.setDescription("calculated,idLookup"); uniqueProperty2.setTitle("Unique property 2"); objectProperties.put("uniqueProperty1", uniqueProperty1); objectProperties.put("uniqueProperty2", uniqueProperty2); final ObjectSchema objectSchema = new ObjectSchema(); objectSchema.setId("urn:jsonschema:org:apache:camel:component:salesforce:dto:SimpleObject"); objectSchema.setProperties(objectProperties); payload = new ObjectSchema(); payload.setOneOf(Collections.singleton(objectSchema)); }
Example #22
Source File: GenerateSearchAnalyticsDataImpl.java From searchanalytics-bigdata with MIT License | 6 votes |
@Override public String generateSearchQueryInstructionJsonSchema() { String jsonSchemaAsString = null; try { ObjectMapper mapper = getObjectMapper(); SchemaFactoryWrapper visitor = new SchemaFactoryWrapper(); mapper.acceptJsonFormatVisitor( mapper.constructType(SearchQueryInstruction.class), visitor); JsonSchema schema = visitor.finalSchema(); jsonSchemaAsString = mapper.writeValueAsString(schema); } catch (JsonProcessingException e) { throw new RuntimeException("Error occured generating json schema!", e); } return jsonSchemaAsString; }
Example #23
Source File: JsonSchemaUtil.java From mPaaS with Apache License 2.0 | 6 votes |
/** 根据schema转换 */ private static Object convertArrayItem(Object src, Items items, boolean checkReadOnly, boolean ignoreException, String path) { if (src == null) { return null; } if (items.isSingleItems()) { JsonSchema schema = items.asSingleItems().getSchema(); if (schema == null) { return src; } return convert(src, schema, checkReadOnly, ignoreException, path); } else if (items.isArrayItems()) { return src; } else { return src; } }
Example #24
Source File: JsonSchemaUtil.java From mPaaS with Apache License 2.0 | 6 votes |
/** 根据schema转换 */ public static Object convert(Object src, JsonSchema schema, boolean checkReadOnly, boolean ignoreException, String path) { if (src == null) { return null; } if (schema.isArraySchema()) { return convertArray(src, schema.asArraySchema(), checkReadOnly, ignoreException, path); } else if (schema.isObjectSchema()) { return convertObject(src, schema.asObjectSchema(), checkReadOnly, ignoreException, path); } else if (schema.isBooleanSchema()) { return TypeUtil.cast(src, Boolean.class); } else if (schema.isIntegerSchema()) { return TypeUtil.cast(src, Long.class); } else if (schema.isNumberSchema()) { return TypeUtil.cast(src, Double.class); } else if (schema.isStringSchema()) { return TypeUtil.cast(src, String.class); } else if (schema.isNullSchema()) { return null; } else { return src; } }
Example #25
Source File: JsonSchemaUtil.java From mPaaS with Apache License 2.0 | 6 votes |
/** 完善JsonSchema信息 */ private static void completeJsonSchema(JsonSchema schema, MetaProperty property) { schema.setDescription(property.getLabel()); if (property.isReadOnly()) { schema.setReadonly(true); } if (property.isNotNull()) { schema.setRequired(true); } if (MetaConstant.isEnum(property) && schema instanceof ValueTypeSchema) { Set<String> enums = new HashSet<>(); for (EnumItem item : property.getEnumList()) { enums.add(item.getValue()); } ((ValueTypeSchema) schema).setEnums(enums); } }
Example #26
Source File: MonetaryAmountSchemaSerializerTest.java From jackson-datatype-money with MIT License | 5 votes |
@Test void shouldSerializeJsonSchema() throws Exception { final ObjectMapper unit = unit(module()); final JsonSchemaGenerator generator = new JsonSchemaGenerator(unit); final JsonSchema jsonSchema = generator.generateSchema(MonetaryAmount.class); final String actual = unit.writeValueAsString(jsonSchema); final String expected = "{\"type\":\"object\",\"id\":\"urn:jsonschema:javax:money:MonetaryAmount\",\"properties\":" + "{\"amount\":{\"type\":\"number\",\"required\":true}," + "\"currency\":{\"type\":\"string\",\"required\":true}," + "\"formatted\":{\"type\":\"string\"}}}"; assertThat(actual, is(expected)); }
Example #27
Source File: JsonSchemaCompatibilityCheck.java From pulsar with Apache License 2.0 | 5 votes |
private boolean isJsonSchema(SchemaData schemaData) { ObjectMapper objectMapper = getObjectMapper(); try { JsonSchema fromSchema = objectMapper.readValue(schemaData.getData(), JsonSchema.class); return true; } catch (IOException e) { return false; } }
Example #28
Source File: TextAreaSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { Optional.ofNullable(property.getAnnotation(TextArea.class)).ifPresent(annotation -> { if (annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } if (annotation.minLenght() != 0) { ((StringSchema) jsonschema).setMinLength(annotation.minLenght()); } if (annotation.maxLenght() != Integer.MAX_VALUE) { ((StringSchema) jsonschema).setMaxLength(annotation.maxLenght()); } }); }
Example #29
Source File: ComboBoxSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { ComboBox annotation = property.getAnnotation(ComboBox.class); if (annotation != null && annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } }
Example #30
Source File: RadioBoxSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { RadioBox annotation = property.getAnnotation(RadioBox.class); if (annotation != null && annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } }