Examples of generateJsonSchema()


Examples of com.fasterxml.jackson.databind.ObjectMapper.generateJsonSchema()

        .addFilter("filteredBean", SimpleBeanPropertyFilter.filterOutAllExcept(new String[]{"obvious"}));

    public void testGeneratingJsonSchemaWithFilters() throws Exception {
      ObjectMapper mapper = new ObjectMapper();
      mapper.setFilters(secretFilterProvider);
      JsonSchema schema = mapper.generateJsonSchema(FilteredBean.class);
      JsonNode node = schema.getSchemaNode().get("properties");
      assertTrue(node.has("obvious"));
      assertFalse(node.has("secret"));
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.generateJsonSchema()

        String className = ((ScalarNode) node).getValue();
        try
        {
            Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
            ObjectMapper objectMapper = new ObjectMapper();
            JsonSchema jsonSchema = objectMapper.generateJsonSchema(clazz);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            objectMapper.writeValue(baos, jsonSchema);
            String schema = baos.toString();
            return new ScalarNode(Tag.STR, schema, node.getStartMark(), node.getEndMark(), ((ScalarNode) node).getStyle());
        }
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.generateJsonSchema()

    }

    public static String getJsonSchema() {
        ObjectMapper m = new ObjectMapper();
        try {
            JsonSchema js = m.generateJsonSchema(OutputTemplate.class);
            return m.writeValueAsString(js);
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

     * @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"));
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

     */
    public void testGeneratingJsonSchema()
        throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        JsonSchema jsonSchema = mapper.generateJsonSchema(SimpleBean.class);
        assertNotNull(jsonSchema);

        // test basic equality, and that equals() handles null, other obs
        assertTrue(jsonSchema.equals(jsonSchema));
        assertFalse(jsonSchema.equals(null));
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

     */
    public void testSchemaSerialization()
            throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        JsonSchema jsonSchema = mapper.generateJsonSchema(SimpleBean.class);
  Map<String,Object> result = writeAndMap(mapper, jsonSchema);
  assertNotNull(result);
  // no need to check out full structure, just basics...
  assertEquals("object", result.get("type"));
  // only add 'required' if it is true...
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

        throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        // not ok to pass null
        try {
            mapper.generateJsonSchema(null);
        } catch (IllegalArgumentException iae) { }
    }

    /**
     * Test for [JACKSON-454]
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

     * Test for [JACKSON-454]
     */
    public void testThatObjectsHaveNoItems() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        JsonSchema jsonSchema = mapper.generateJsonSchema(TrivialBean.class);
        String json = jsonSchema.toString().replaceAll("\"", "'");
        // can we count on ordering being stable? I think this is true with current ObjectNode impl
        // as perh [JACKSON-563]; 'required' is only included if true
        assertEquals("{'type':'object','properties':{'name':{'type':'string'}}}",
                json);
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

    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();
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper.generateJsonSchema()

     */
    public void testGeneratingJsonSchema()
        throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        JsonSchema jsonSchema = mapper.generateJsonSchema(SimpleBean.class);
        assertNotNull(jsonSchema);

        // test basic equality, and that equals() handles null, other obs
        assertTrue(jsonSchema.equals(jsonSchema));
        assertFalse(jsonSchema.equals(null));
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.