Examples of JSONSchema


Examples of org.codehaus.jackson.schema.JsonSchema

     * @since 1.7
     */
    public void testWithJaxb() throws Exception
    {
        ObjectMapper mapper = getJaxbMapper();
        JsonSchema jsonSchema = mapper.generateJsonSchema(Address.class);
        ObjectNode root = jsonSchema.getSchemaNode();
        // should find two properties ("city", "state"), not just one...
        JsonNode itemsNode = root.findValue("properties");
        assertNotNull("Missing 'state' field", itemsNode.get("state"));
        assertNotNull("Missing 'city' field", itemsNode.get("city"));
        assertEquals(2, itemsNode.size());
View Full Code Here

Examples of org.codehaus.jackson.schema.JsonSchema

        if (!(schemaNode instanceof ObjectNode)) {
            throw new IllegalArgumentException("Class " + type.getName() +
                    " would not be serialized as a JSON object and therefore has no schema");
        }

        return new JsonSchema((ObjectNode) schemaNode);
    }
View Full Code Here

Examples of org.codehaus.jackson.schema.JsonSchema

    columnFamily2.setRows(rows2);
    columnFamilies.add(columnFamily2);

    ObjectMapper jSONMapper = new ObjectMapper();
    try {
      JsonSchema schema = jSONMapper.generateJsonSchema(ParsedKeyspace.class);
      log.debug(schema.toString());
      log.debug(jSONMapper.writeValueAsString(keyspace));
    } catch (JsonMappingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (JsonGenerationException e) {
View Full Code Here

Examples of org.codehaus.jackson.schema.JsonSchema

        if (!(schemaNode instanceof ObjectNode)) {
            throw new IllegalArgumentException("Class " + type.getName() +
                    " would not be serialized as a JSON object and therefore has no schema");
        }

        return new JsonSchema((ObjectNode) schemaNode);
    }
View Full Code Here

Examples of org.codehaus.jackson.schema.JsonSchema

        if (!(schemaNode instanceof ObjectNode)) {
            throw new IllegalArgumentException("Class " + type.getName() +
                    " would not be serialized as a JSON object and therefore has no schema.");
        }

        return new JsonSchema((ObjectNode) schemaNode);
    }
View Full Code Here

Examples of org.codehaus.jackson.schema.JsonSchema

        if (!(schemaNode instanceof ObjectNode)) {
            throw new IllegalArgumentException("Class " + type.getName() +
                    " would not be serialized as a JSON object and therefore has no schema.");
        }

        return new JsonSchema((ObjectNode) schemaNode);
    }
View Full Code Here

Examples of org.eclipse.persistence.internal.jaxb.json.schema.model.JsonSchema

        }
    }
   
    public JsonSchema generateSchema(Class rootClass) {
        this.rootClass = rootClass;
        schema = new JsonSchema();
        schema.setTitle(rootClass.getName());
       
        //Check for simple type
        JsonType rootType = getJsonTypeForJavaType(rootClass);
        if(rootType != JsonType.OBJECT) {
View Full Code Here

Examples of org.eclipse.persistence.internal.jaxb.json.schema.model.JsonSchema

        }
    }

    public void generateJsonSchema(SchemaOutputResolver outputResolver, Class rootClass) {
        JsonSchemaGenerator generator = new JsonSchemaGenerator(this.contextState.getXMLContext(), this.contextState.properties);
        JsonSchema schema = generator.generateSchema(rootClass);
        try {
            Marshaller m = getJsonSchemaMarshaller();
            m.marshal(schema, outputResolver.createOutput(null, rootClass.getName() + ".json"));
        } catch (Exception ex) {
        }
View Full Code Here

Examples of org.springframework.data.rest.webmvc.json.JsonSchema

   * @return
   */
  @RequestMapping(value = BASE_MAPPING + "/schema", method = GET, produces = { "application/schema+json" })
  public HttpEntity<JsonSchema> schema(RootResourceInformation resourceInformation) {

    JsonSchema schema = jsonSchemaConverter.convert(resourceInformation.getDomainType());
    return new ResponseEntity<JsonSchema>(schema, HttpStatus.OK);
  }
View Full Code Here

Examples of uk.co.o2.json.schema.JsonSchema

    private JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());
    private SchemaPassThroughCache schemaFactory = new SchemaPassThroughCache(jsonFactory);

    @Test
    public void validateSchema_shouldWorkFromADifferentPackage() throws Exception {
        JsonSchema schema = schemaFactory.getSchema(getClass().getClassLoader().getResource("sample-json-schema.json"));
        JsonNode json = jsonFactory.createJsonParser(getClass().getClassLoader().getResource("valid-json-document.json")).readValueAsTree();

        List<ErrorMessage> errors = schema.validate(json);

        assertTrue(errors.isEmpty());
    }
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.