3

In online tool http://www.jsonschema2pojo.org/ there is an option to set Class Name, so the generated root class will be named as I want it. I cant find the same option in maven-plugin option and the generated root class has default name: OutputSchema.java Is there a way to set it up? My pom.xml

            <plugin>
            <groupId>org.jsonschema2pojo</groupId>
            <artifactId>jsonschema2pojo-maven-plugin</artifactId>
            <version>0.5.1</version>
            <configuration>
                <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
                <outputDirectory>${basedir}/src/main/java</outputDirectory>
                <targetPackage>com.test.generated</targetPackage>
                <targetVersion>1.8</targetVersion>
                <sourceType>json</sourceType>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

2 Answers2

2

Note there is also the option called

<useTitleAsClassname>true</useTitleAsClassname>

If you use this, the class name will be what you specified in the title attribute of your schema.

https://github.com/joelittlejohn/jsonschema2pojo/issues/908

user828878
  • 398
  • 4
  • 8
1

Ok, I've found the solution by myself. The class name is generated from the input json file name. For example output-schema.json will generate OutputSchema.java class