Package com.fasterxml.jackson.module.jsonSchema.factories

Examples of com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper


            // skip non-jackson mapped classes (like Response)
            if (!type.isAnnotationPresent(JsonAutoDetect.class)) {
                continue;
            }
            try {
                SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
                mapper.acceptJsonFormatVisitor(mapper.constructType(type), visitor);
                final JsonSchema schema = visitor.finalSchema();
                models.put(type.getSimpleName(), schema);
            } catch (JsonMappingException e) {
                LOG.error("Error generating model schema. Ignoring this model, this will likely break the API browser.", e);
            }
View Full Code Here


public class TitleSchemaFactoryWrapper extends SchemaFactoryWrapper
{
    private static class TitleSchemaFactoryWrapperFactory extends WrapperFactory {
      @Override
      public SchemaFactoryWrapper getWrapper(SerializerProvider p) {
          SchemaFactoryWrapper wrapper = new TitleSchemaFactoryWrapper();
          wrapper.setProvider(p);
          return wrapper;
      };
View Full Code Here

      _wrapperFactory = wrapperFactory == null ? new WrapperFactory() : wrapperFactory;
    }

    public JsonSchema generateSchema(Class<?> type) throws JsonMappingException
    {
        SchemaFactoryWrapper visitor = _wrapperFactory.getWrapper(_mapper == null ? null : _mapper.getSerializerProvider());
        _mapper.acceptJsonFormatVisitor(type, visitor);
        return visitor.finalSchema();
    }
View Full Code Here

        return visitor.finalSchema();
    }

    public JsonSchema generateSchema(JavaType type) throws JsonMappingException
    {
        SchemaFactoryWrapper visitor = _wrapperFactory.getWrapper(_mapper == null ? null : _mapper.getSerializerProvider());
        _mapper.acceptJsonFormatVisitor(type, visitor);
        return visitor.finalSchema();
    }
View Full Code Here

    public void testMapTypes() throws Exception {
        _testSimple(SchemableMaps.class);
    }
   
    public void testAdditionalItems() throws Exception {
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        MAPPER.acceptJsonFormatVisitor(MAPPER.constructType(SchemableArrays.class), visitor);
        JsonSchema jsonSchema = visitor.finalSchema();
        assertNotNull(jsonSchema);
       
        assertTrue(jsonSchema.isObjectSchema());
        for (JsonSchema propertySchema : jsonSchema.asObjectSchema().getProperties().values())
        {
View Full Code Here

        _testSimple("SchemableArrays - additionalItems", jsonSchema);
    }

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

     /**********************************************************
     */
    public void testInvalidCall() throws Exception {
        // not ok to pass null
        try {
            SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
            MAPPER.acceptJsonFormatVisitor((JavaType) null, visitor);
            fail("Should have failed");
        } catch (IllegalArgumentException iae) {
            verifyException(iae, "type must be provided");
        }
View Full Code Here

    public void testJsonValueAnnotation() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(Leaf.class), visitor);
        JsonSchema schemaExp = visitor.finalSchema();
        assertNotNull(schemaExp);
       
        visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(ContainerWithAsValue.class), visitor);
        JsonSchema schemaAct = visitor.finalSchema();
        assertNotNull(schemaAct);

        // these are minimal checks:
        assertEquals(schemaExp.getType(), schemaAct.getType());
        assertEquals(schemaExp, schemaAct);
View Full Code Here

    // For [Issue#34]
    public void testJsonValueForCollection() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        mapper.acceptJsonFormatVisitor(mapper.constructType(Issue34Bean.class), visitor);
        JsonSchema schema = visitor.finalSchema();
        assertNotNull(schema);
       
        String schemaStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
        assertNotNull(schemaStr);
    }
View Full Code Here

    private final static ObjectMapper MAPPER = new ObjectMapper();
   
    private String generateSchema(Class<?> clazz) throws Exception
    {
        MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        MAPPER.acceptJsonFormatVisitor(MAPPER.constructType(clazz), visitor);
        return MAPPER.writeValueAsString(visitor.finalSchema());
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper

Copyright © 2018 www.massapicom. 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.