@@ -17,6 +17,8 @@ plugins {
1717 id ' com.palantir.git-version' version ' 0.13.0'
1818 // auto release to maven central (skip sonatype manual nexus release process)
1919 id(" io.github.gradle-nexus.publish-plugin" ) version " 1.1.0"
20+ // translate json schemas to java classes
21+ id " org.jsonschema2pojo" version " 1.1.3"
2022}
2123
2224// It is important to set the group and the version to the root project
@@ -41,20 +43,107 @@ java {
4143
4244// package dependencies
4345dependencies {
46+ // swagger
47+ implementation ' io.swagger:swagger-annotations:1.6.5'
48+
49+ // http client
50+ implementation ' com.squareup.okhttp3:okhttp:4.9.3'
51+ implementation ' com.squareup.okhttp3:logging-interceptor:4.9.3'
52+
53+ // json serialization and deserialization
54+ implementation ' com.google.code.gson:gson:2.9.0'
55+ implementation ' io.gsonfire:gson-fire:1.8.5'
56+
57+ // openapi annotations
58+ implementation ' javax.ws.rs:jsr311-api:1.1.1'
59+ implementation ' javax.ws.rs:javax.ws.rs-api:2.1.1'
60+ implementation ' org.openapitools:jackson-databind-nullable:0.2.3'
61+ implementation group : ' org.apache.commons' , name : ' commons-lang3' , version : ' 3.12.0'
62+ implementation " jakarta.annotation:jakarta.annotation-api:1.3.5"
63+
64+ // logger
4465 implementation ' ch.qos.logback:logback-classic:1.2.10'
4566 implementation ' ch.qos.logback:logback-core:1.2.10'
4667 implementation ' org.slf4j:slf4j-api:1.7.33'
4768
69+
70+
4871 // Use JUnit Jupiter for testing.
4972 testImplementation ' org.junit.jupiter:junit-jupiter:5.7.2'
5073
5174 // These dependencies are used internally, and not exposed to consumers on their own compile classpath.
5275 // google standard java library
5376 implementation ' com.google.guava:guava:30.1.1-jre'
54- // json serialization and deserialization
55- implementation ' com.google.code.gson:gson:2.8.9'
56- // http client
57- implementation ' com.squareup.okhttp3:okhttp:4.9.3'
77+
78+
79+ }
80+
81+ jsonSchema2Pojo {
82+ // Location of the JSON Schema file(s). This may refer to a single file or a directory of files.
83+ source = files(" schemas/" )
84+
85+ // Target directory for generated Java source files. The plugin will add this directory to the
86+ // java source set so the compiler will find and compile the newly generated source files.
87+ targetDirectory = file(" src/main/java" )
88+
89+ // Package name used for generated Java classes (for types where a fully qualified name has not
90+ // been supplied in the schema using the 'javaType' property).
91+ targetPackage = ' io.permit.sdk.openapi.models'
92+
93+ // Whether to allow 'additional' properties to be supported in classes by adding a map to
94+ // hold these. This is true by default, meaning that the schema rule 'additionalProperties'
95+ // controls whether the map is added. Set this to false to globally disable additional properties.
96+ includeAdditionalProperties = false
97+
98+ // Whether to include a javax.annotation.Generated (Java 8 and lower) or
99+ // javax.annotation.processing.Generated (Java 9+) in on generated types (default true).
100+ // See also: targetVersion.
101+ includeGeneratedAnnotation = true
102+
103+ // Whether to use the 'title' property of the schema to decide the class name (if not
104+ // set to true, the filename and property names are used).
105+ useTitleAsClassname = true
106+
107+ // Whether to empty the target directory before generation occurs, to clear out all source files
108+ // that have been generated previously. <strong>Be warned</strong>, when activated this option
109+ // will cause jsonschema2pojo to <strong>indiscriminately delete the entire contents of the target
110+ // directory (all files and folders)</strong> before it begins generating sources.
111+ removeOldOutput = false
112+
113+ // Whether to generate builder-style methods of the form withXxx(value) (that return this),
114+ // alongside the standard, void-return setters.
115+ generateBuilders = true
116+
117+ // If set to true, then the gang of four builder pattern will be used to generate builders on
118+ // generated classes. Note: This property works in collaboration with generateBuilders.
119+ // If generateBuilders is false then this property will not do anything.
120+ useInnerClassBuilders = false
121+
122+ // Whether to include hashCode and equals methods in generated Java types.
123+ includeHashcodeAndEquals = false
124+
125+ // Whether to include a toString method in generated Java types.
126+ includeToString = false
127+
128+ // Whether to include getters or to omit these accessor methods and create public fields instead.
129+ includeGetters = false
130+
131+ // Whether to include setters or to omit these accessor methods and create public fields instead.
132+ includeSetters = false
133+
134+ // Whether to use java.util.Optional for getters on properties that are not required
135+ useOptionalForGetters = true
136+
137+ // Whether to generate constructors or not.
138+ includeConstructors = true
139+
140+ // Whether to include only 'required' fields in generated constructors
141+ constructorsRequiredPropertiesOnly = true
142+
143+ annotationStyle = ' gson'
144+
145+ // Whether to initialize Set and List fields as empty collections, or leave them as null.
146+ initializeCollections = false
58147}
59148
60149publishing {
0 commit comments