Extension jsonSchema2Pojo
is used to configure generator of Java POJO classes from JSON/YAML schema
Extension allows to define target directory prefix and executions. Each execution defines parameters for Java POJOs generation using underlying library.
Name | Type | Default | Description | Notes |
---|---|---|---|---|
targetDirectoryPrefix |
String |
$buildDir/generated/sources/js2d |
Directory property to define prefix under build directory where underlying tool will generate sources |
|
executions |
Set of named executions |
Execution with parameters. |
Execution name must follow the regular expression |
Execution block specifies parameters listed below needed to process JSON schema to POJOs. All enum parameters are case-insensitive for a convenience.
Most of the parameters has defaults defined in jsonschema2pojo
library.
All parameters and options listed are Gradle properties of given type.
The only exception is source
which is ConfigurableFileCollection
.
Name | Description | Notes | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
annotationStyle |
The style of annotations to use in the generated Java types. Supported values
|
|||||||||||||||||||
classNamePrefix |
Whether to add a prefix to generated classes. |
|||||||||||||||||||
classNameSuffix |
Whether to add a suffix to generated classes. |
|||||||||||||||||||
constructorsRequiredPropertiesOnly |
This is a legacy configuration option and will be removed in subsequent releases.
This option turns on the |
This option will do nothing if |
||||||||||||||||||
customAnnotator |
A fully qualified class name, referring to a custom annotator class that implements |
If you want to use the custom annotator alone, set |
||||||||||||||||||
customDatePattern |
A custom pattern to use when formatting date fields during serialization. |
Requires support from your JSON binding library. |
||||||||||||||||||
customDateTimePattern |
A custom pattern to use when formatting date-time fields during serialization. |
Requires support from your JSON binding library. |
||||||||||||||||||
customRuleFactory |
A fully qualified class name, referring to a class that extends |
|||||||||||||||||||
customTimePattern |
A custom pattern to use when formatting time fields during serialization. |
Requires support from your JSON binding library. |
||||||||||||||||||
dateTimeType |
Which type to use instead of string when adding string type fields of format date-time to generated Java types. |
|||||||||||||||||||
dateType |
Which type to use instead of string when adding string type fields of format date (not date-time) to generated Java types. |
|||||||||||||||||||
fileExtensions |
The strings (no preceding dot) that should be considered as file name extensions, and therefore ignored, when creating Java class names. |
|||||||||||||||||||
fileFilter |
List of file patterns to exclude. |
This only applies to the initial scan of the file system. Option will not prevent inclusion through a "$ref" in one of the schemas. |
||||||||||||||||||
formatDateTimes |
Whether the fields of date type are formatted during serialization. |
Default pattern is |
||||||||||||||||||
formatDates |
Whether the fields of date type are formatted during serialization. |
Default pattern is with a default pattern of |
||||||||||||||||||
formatTimes |
Whether the fields of time type are formatted during serialization. |
Default pattern of |
||||||||||||||||||
formatTypeMapping |
Defines mapping from format identifier (e.g. 'uri') to fully qualified type name (e.g. 'java.net.URI'). |
|||||||||||||||||||
generateBuilders |
Whether to generate builder-style methods of the form withXxx(value) that return this, alongside the standard, void-return setters. |
|||||||||||||||||||
includeAdditionalProperties |
Whether to allow 'additional properties' support in objects. Setting this to false will disable additional properties support, regardless of the input schema(s). |
|||||||||||||||||||
includeAllPropertiesConstructor |
This option determines whether the resulting object should include a constructor with all listed properties as parameters. |
This option will have no effect if |
||||||||||||||||||
includeConstructorPropertiesAnnotation |
Whether to include JDK |
May not be available on Android |
||||||||||||||||||
includeConstructors |
Whether to generate constructors or not |
|||||||||||||||||||
includeCopyConstructor |
Generate copy constructor to assign all properties from the originating class to the new class. |
This option works in collaboration with the |
||||||||||||||||||
includeDynamicAccessors |
Whether to include dynamic getters, setters, and builders or to omit these methods. |
|||||||||||||||||||
includeDynamicBuilders |
Whether to include dynamic builders or to omit these methods. |
|||||||||||||||||||
includeDynamicGetters |
Whether to include dynamic getters or to omit these methods. |
|||||||||||||||||||
includeDynamicSetters |
Whether to include dynamic setters or to omit these methods. |
|||||||||||||||||||
includeGeneratedAnnotation |
Whether to mark generated classes with the |
It strongly depends on java version used to run POJO generator, not |
||||||||||||||||||
includeGetters |
Whether to include getters or to omit this accessor method and create public fields instead |
|||||||||||||||||||
includeHashcodeAndEquals |
Whether to include hashCode and equals methods in generated Java types. |
Note, that |
||||||||||||||||||
includeJsr303Annotations |
Whether to include JSR-303/349 annotations in generated Java types for various field constraints defined in schema. Any Java fields which are an object or array of objects will be annotated with @Valid to support validation.
|
|||||||||||||||||||
includeJsr305Annotations |
Whether to include JSR-305 annotations (for schema rules like Nullable, NonNull, etc.) in generated Java types. |
|||||||||||||||||||
includeRequiredPropertiesConstructor |
This option determines whether the resulting object should include a constructor with only the required properties as parameters. |
This option works in collaboration with the |
||||||||||||||||||
includeSetters |
Whether to include setters or to omit this accessor method and create public fields instead |
|||||||||||||||||||
includeToString |
Whether to include a toString method in generated Java types. |
|||||||||||||||||||
includeTypeInfo |
Whether to include json type information.
This is often required to support polymorphic type handling.
By default, the type information is stored in the |
Works only if |
||||||||||||||||||
inclusionLevel |
The Level of inclusion to set in the generated Java types for Jackson serializers. Supported values
|
Works only if |
||||||||||||||||||
initializeCollections |
Whether to initialize Set and List fields as empty collections, or leave them as null. |
|||||||||||||||||||
outputEncoding |
The character encoding that should be used when writing the generated Java source files. |
|||||||||||||||||||
parcelable |
Whether to make the generated types |
Used for Android development. |
||||||||||||||||||
propertyWordDelimiters |
The characters that should be considered as word delimiters when creating Java Bean property names from JSON property names. If blank or not set, JSON properties will be considered to contain a single word when creating Java Bean property names. |
|||||||||||||||||||
refFragmentPathDelimiters |
A string containing any characters that should act as path delimiters when resolving $ref fragments.
By default, |
|||||||||||||||||||
removeOldOutput |
Whether to empty the target directory before generation occurs, to clear out all source files that have been generated previously. Be warned, when activated this option will cause jsonschema2pojo to indiscriminately delete the entire contents of the target directory (all files and folders) before it begins generating sources. |
|||||||||||||||||||
serializable |
Whether to make the generated types |
|||||||||||||||||||
source |
Location of the JSON Schema file(s). |
this may refer to a single file or a directory of files. |
||||||||||||||||||
sourceSortOrder |
The sort order to be applied when recursively processing the source files. By default, the OS can influence the processing order. Supported values
|
|||||||||||||||||||
sourceType |
The type of input documents that will be read. Supported values
|
|||||||||||||||||||
targetPackage |
Package name prefix used for generated Java classes.
This is used for types where a fully qualified name has not been supplied in the schema using the |
|||||||||||||||||||
targetVersion |
The target version for generated source files. |
|||||||||||||||||||
timeType |
What type to use instead of string when adding string type fields of format time (not date-time) to generated Java types. |
|||||||||||||||||||
toStringExcludes |
The fields to be excluded from toString generation |
|||||||||||||||||||
useBigDecimals |
Whether to use the java type BigDecimal instead of float (or Float) when representing the JSON Schema type 'number'. |
This parameter overrides |
||||||||||||||||||
useBigIntegers |
Whether to use the java type |
This parameter overrides |
||||||||||||||||||
useDoubleNumbers |
Whether to use the java type |
|||||||||||||||||||
useInnerClassBuilders |
If set to true, then the gang of four builder pattern will be used to generate builders on generated classes. |
If the |
||||||||||||||||||
useJodaDates |
Whether to use |
|||||||||||||||||||
useJodaLocalDates |
Whether to use |
|||||||||||||||||||
useJodaLocalTimes |
Whether to use |
|||||||||||||||||||
useLongIntegers |
Whether to use the java type |
|||||||||||||||||||
useOptionalForGetters |
Whether to use Optional as return type for getters of non-required fields. |
|||||||||||||||||||
usePrimitives |
Whether to use primitives ( |
This has the side effect of making those properties non-null. |
||||||||||||||||||
useTitleAsClassname |
Use the title as class name. Otherwise, the property and file name is used. |
Supported parameters and options (types and their defaults)
Name | Type | Default |
---|---|---|
annotationStyle |
String |
jackson2 |
classNamePrefix |
String |
|
classNameSuffix |
String |
|
constructorsRequiredPropertiesOnly |
boolean |
false |
customAnnotator |
String |
org.jsonschema2pojo.NoopAnnotator |
customDatePattern |
String |
|
customDateTimePattern |
String |
|
customRuleFactory |
String |
org.jsonschema2pojo.rules.RuleFactory |
customTimePattern |
String |
|
dateTimeType |
String |
|
dateType |
String |
|
fileExtensions |
List<String> |
|
fileFilter |
FileFilter |
|
formatDateTimes |
boolean |
false |
formatDates |
boolean |
false |
formatTimes |
boolean |
false |
formatTypeMapping |
|
|
generateBuilders |
boolean |
false |
includeAdditionalProperties |
boolean |
true |
includeAllPropertiesConstructor |
boolean |
true |
includeConstructorPropertiesAnnotation |
boolean |
false |
includeConstructors |
boolean |
false |
includeCopyConstructor |
boolean |
false |
includeDynamicAccessors |
boolean |
false |
includeDynamicBuilders |
boolean |
false |
includeDynamicGetters |
boolean |
false |
includeDynamicSetters |
boolean |
false |
includeGeneratedAnnotation |
boolean |
false |
includeGetters |
boolean |
true |
includeHashcodeAndEquals |
boolean |
true |
includeJsr303Annotations |
boolean |
false |
includeJsr305Annotations |
boolean |
false |
includeRequiredPropertiesConstructor |
boolean |
false |
includeSetters |
boolean |
true |
includeToString |
boolean |
true |
includeTypeInfo |
boolean |
false |
inclusionLevel |
String |
NON_NULL |
initializeCollections |
boolean |
true |
outputEncoding |
String |
UTF-8 |
parcelable |
boolean |
false |
propertyWordDelimiters |
String |
|
refFragmentPathDelimiters |
String |
|
removeOldOutput |
boolean |
false |
serializable |
boolean |
|
source |
ConfigurableFileCollection |
|
sourceSortOrder |
String |
OS |
sourceType |
String |
jsonschema |
targetPackage |
String |
|
targetVersion |
String |
|
timeType |
String |
|
toStringExcludes |
List<String> |
|
useBigDecimals |
boolean |
false |
useBigIntegers |
boolean |
false |
useDoubleNumbers |
boolean |
true |
useInnerClassBuilders |
boolean |
false |
useJodaDates |
boolean |
false |
useJodaLocalDates |
boolean |
false |
useJodaLocalTimes |
boolean |
false |
useLongIntegers |
boolean |
false |
useOptionalForGetters |
boolean |
false |
usePrimitives |
boolean |
false |
useTitleAsClassname |
boolean |
false |