Examples of JsonSchema


Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

    public void valueFormat(JsonFormatVisitable handler, JavaType valueType)
            throws JsonMappingException {

        // ISSUE #24: https://github.com/FasterXML/jackson-module-jsonSchema/issues/24
       
        JsonSchema valueSchema = propertySchema(handler, valueType);
        ObjectSchema.AdditionalProperties ap = new ObjectSchema.SchemaAdditionalProperties(valueSchema.asSimpleTypeSchema());
        this.schema.setAdditionalProperties(ap);
    }
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

    public ObjectSchema.AdditionalProperties deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        ObjectMapper mapper = (ObjectMapper) jp.getCodec();
        TreeNode node = mapper.readTree(jp);
        String nodeStr = mapper.writeValueAsString(node);
        if (node instanceof ObjectNode) {
            JsonSchema innerSchema = mapper.readValue(nodeStr, JsonSchema.class);
            return new ObjectSchema.SchemaAdditionalProperties(innerSchema);
        } else if (node instanceof BooleanNode) {
            BooleanNode booleanNode = (BooleanNode) node;
            if (booleanNode.booleanValue()) {
                return null; // "additionalProperties":true is the default
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

      TreeNode node = jp.readValueAsTree();
   
    if (node instanceof ObjectNode) {
        // not clean, but has to do...
            ObjectMapper mapper = (ObjectMapper) jp.getCodec();
      JsonSchema innerSchema = mapper.treeToValue(node, JsonSchema.class);
      return new ArraySchema.SchemaAdditionalItems(innerSchema);
    }
    if (node instanceof BooleanNode) {
      BooleanNode booleanNode = (BooleanNode) node;
      if (booleanNode.booleanValue()) {
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

      Object typeFound = props.get("type");
      if (typeFound == null || ! (typeFound instanceof String)) {
        return null;
      }
      String type = (String) typeFound;
      JsonSchema schema = JsonSchema.minimalForFormat(JsonFormatTypes.forValue(type));
      //KNOWN ISSUE: pending https://github.com/FasterXML/jackson-databind/issues/43
      //only deserialize items as minimal schema for type
      return new SingleItems(schema);
    }
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

    public void valueFormat(JsonFormatVisitable handler, JavaType valueType)
            throws JsonMappingException {

        // ISSUE #24: https://github.com/FasterXML/jackson-module-jsonSchema/issues/24
       
        JsonSchema valueSchema = propertySchema(handler, valueType);
        ObjectSchema.AdditionalProperties ap = new ObjectSchema.SchemaAdditionalProperties(valueSchema.asSimpleTypeSchema());
        this.schema.setAdditionalProperties(ap);
    }
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

   
    // [Issue#14]: multiple type attributes
    public void testCorrectType() throws Exception
    {
        JsonSchemaGenerator generator = new JsonSchemaGenerator(MAPPER);
        JsonSchema jsonSchema = generator.generateSchema(Issue14Bean.class);
        String json = MAPPER.writeValueAsString(jsonSchema).replace('"', '\'');
        final String EXP = "{'type':'object'," +
                "'id':'urn:jsonschema:com:fasterxml:jackson:module:jsonSchema:TestTypeGeneration:Issue14Bean'," +
                "'properties':{'date':{'type':'integer','format':'UTC_MILLISEC'}}}";
        assertEquals(EXP, json);
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

    private final ObjectMapper MAPPER = objectMapper();

    public void testUnwrapping()  throws Exception
    {
        JsonSchemaGenerator generator = new JsonSchemaGenerator(MAPPER);
        JsonSchema schema = generator.generateSchema(UnwrappingRoot.class);

        String json = MAPPER.writeValueAsString(schema).replace('"', '\'');
       
//System.err.println("JSON -> "+MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(schema));
        String EXP = "{'type':'object','properties':{"
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

   
    public void _testSimple(Class<?> type) throws Exception
    {
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        MAPPER.acceptJsonFormatVisitor(MAPPER.constructType(type), visitor);
        JsonSchema jsonSchema = visitor.finalSchema();
        assertNotNull(jsonSchema);

        String schemaStr = MAPPER.writeValueAsString(jsonSchema);
        assertNotNull(schemaStr);
        JsonSchema result = MAPPER.readValue(schemaStr, JsonSchema.class);
        String resultStr = MAPPER.writeValueAsString(result);
        JsonNode node = MAPPER.readTree(schemaStr);
        JsonNode finalNode = MAPPER.readTree(resultStr);

        String json1 = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(node);
View Full Code Here

Examples of com.github.fge.jsonschema.main.JsonSchema

        final LoadingConfiguration cfg = LoadingConfiguration.newBuilder()
            .dereferencing(Dereferencing.INLINE).freeze();
        final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder()
            .setLoadingConfiguration(cfg).freeze();

        final JsonSchema schema = factory.getJsonSchema(fstabSchema);

        ProcessingReport report;

        report = schema.validate(good);
        System.out.println(report);

        report = schema.validate(bad);
        System.out.println(report);

        report = schema.validate(bad2);
        System.out.println(report);
    }
View Full Code Here

Examples of com.github.fge.jsonschema.main.JsonSchema

        final JsonNode bad = Utils.loadResource("/fstab-bad.json");
        final JsonNode bad2 = Utils.loadResource("/fstab-bad2.json");

        final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();

        final JsonSchema schema = factory.getJsonSchema(SCHEMA_URI);

        ProcessingReport report;

        report = schema.validate(good);
        System.out.println(report);

        report = schema.validate(bad);
        System.out.println(report);

        report = schema.validate(bad2);
        System.out.println(report);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.