Search in sources :

Example 1 with DefaultGenerationConfig

use of org.jsonschema2pojo.DefaultGenerationConfig 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 = new URL("file:///path/to/my/schema.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(new File("output"));
// 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) File(java.io.File) URL(java.net.URL) GenerationConfig(org.jsonschema2pojo.GenerationConfig) DefaultGenerationConfig(org.jsonschema2pojo.DefaultGenerationConfig) SchemaMapper(org.jsonschema2pojo.SchemaMapper)

Example 2 with DefaultGenerationConfig

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

the class RuleFactoryImplTest method schemaStoreIsReturned.

@Test
public void schemaStoreIsReturned() {
    SchemaStore mockSchemaStore = mock(SchemaStore.class);
    RuleFactory ruleFactory = new RuleFactory(new DefaultGenerationConfig(), new NoopAnnotator(), mockSchemaStore);
    assertThat(ruleFactory.getSchemaStore(), is(sameInstance(mockSchemaStore)));
}
Also used : DefaultGenerationConfig(org.jsonschema2pojo.DefaultGenerationConfig) SchemaStore(org.jsonschema2pojo.SchemaStore) NoopAnnotator(org.jsonschema2pojo.NoopAnnotator) Test(org.junit.Test)

Aggregations

DefaultGenerationConfig (org.jsonschema2pojo.DefaultGenerationConfig)2 SchemaStore (org.jsonschema2pojo.SchemaStore)2 JCodeModel (com.sun.codemodel.JCodeModel)1 File (java.io.File)1 URL (java.net.URL)1 GenerationConfig (org.jsonschema2pojo.GenerationConfig)1 Jackson2Annotator (org.jsonschema2pojo.Jackson2Annotator)1 NoopAnnotator (org.jsonschema2pojo.NoopAnnotator)1 SchemaGenerator (org.jsonschema2pojo.SchemaGenerator)1 SchemaMapper (org.jsonschema2pojo.SchemaMapper)1 RuleFactory (org.jsonschema2pojo.rules.RuleFactory)1 Test (org.junit.Test)1