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

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


        _testSimple(SchemableEnumMap.class);
    }
   
    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);
View Full Code Here


    public static String generateJsonSchema(Class<?> clazz) {


        ObjectMapper mapper = new ObjectMapper();
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        try {
            mapper.acceptJsonFormatVisitor(clazz, visitor);

            JsonSchema schema = visitor.finalSchema();
            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);

        } catch (JsonMappingException e) {
            log.error("Error occurred while generating JSON schema for the class ["+clazz+"]",e);
        } catch (JsonProcessingException e) {
View Full Code Here

        _mapper = mapper;
    }

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

        return visitor.finalSchema();
    }

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

    private boolean ignoreDefaults = true;

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

                    schemaDef = schemaMap.get(objectClass);

                } else {

                    ObjectMapper objectMapper = new ObjectMapper();
                    SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
                    objectMapper.acceptJsonFormatVisitor(objectClass, visitor);
                    JsonSchema schema = visitor.finalSchema();
                    schemaDef = objectMapper.writeValueAsString(schema);
                    schemaMap.put(objectClass, schemaDef);
                }

                return schemaDef;
View Full Code Here

        this.mapper = mapper;
    }

    @GET("/@/api-docs/schemas/{fqcn}")
    public String getJsonSchema(String fqcn) {
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        try {
            mapper.acceptJsonFormatVisitor(mapper.constructType(Class.forName(fqcn)), visitor);
        } catch (JsonMappingException e) {
            throw new IllegalStateException(e);
        } catch (ClassNotFoundException e) {
            throw new WebException(HttpStatus.NOT_FOUND);
        }
        try {
            return mapper.writerWithDefaultPrettyPrinter()
                    .writeValueAsString(visitor.finalSchema());
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }

    }
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.