Search in sources :

Example 1 with SchemaGenerator

use of org.jsonschema2pojo.SchemaGenerator in project jsonschema2pojo by joelittlejohn.

the class Example method main.

public static void main(String[] args) throws IOException {
    // BEGIN EXAMPLE
    JCodeModel codeModel = new JCodeModel();
    URL source = Example.class.getResource("/schema/required.json");
    GenerationConfig config = new DefaultGenerationConfig() {

        @Override
        public boolean isGenerateBuilders() {
            // set config option by overriding method
            return true;
        }
    };
    SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, new Jackson2Annotator(config), new SchemaStore()), new SchemaGenerator());
    mapper.generate(codeModel, "ClassName", "com.example", source);
    codeModel.build(Files.createTempDirectory("required").toFile());
// END EXAMPLE
}
Also used : DefaultGenerationConfig(org.jsonschema2pojo.DefaultGenerationConfig) RuleFactory(org.jsonschema2pojo.rules.RuleFactory) SchemaStore(org.jsonschema2pojo.SchemaStore) Jackson2Annotator(org.jsonschema2pojo.Jackson2Annotator) SchemaGenerator(org.jsonschema2pojo.SchemaGenerator) JCodeModel(com.sun.codemodel.JCodeModel) URL(java.net.URL) GenerationConfig(org.jsonschema2pojo.GenerationConfig) DefaultGenerationConfig(org.jsonschema2pojo.DefaultGenerationConfig) SchemaMapper(org.jsonschema2pojo.SchemaMapper)

Aggregations

JCodeModel (com.sun.codemodel.JCodeModel)1 URL (java.net.URL)1 DefaultGenerationConfig (org.jsonschema2pojo.DefaultGenerationConfig)1 GenerationConfig (org.jsonschema2pojo.GenerationConfig)1 Jackson2Annotator (org.jsonschema2pojo.Jackson2Annotator)1 SchemaGenerator (org.jsonschema2pojo.SchemaGenerator)1 SchemaMapper (org.jsonschema2pojo.SchemaMapper)1 SchemaStore (org.jsonschema2pojo.SchemaStore)1 RuleFactory (org.jsonschema2pojo.rules.RuleFactory)1