Skip to content

Commit ee538be

Browse files
kassimwing328
authored andcommitted
[Java] add nullable annotation to pojo template for non-required fields (#3409)
* add nullable annotation to pojo template * add jsr305 dependency * jsr305 dependency on all java build.gradle files * jsr305 dependency on all java pom.xml files * update samples * more pom updates * more sample/template updates
1 parent a0dd739 commit ee538be

File tree

994 files changed

+3525
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

994 files changed

+3525
-0
lines changed

modules/openapi-generator/src/main/resources/Java/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ ext {
145145

146146
dependencies {
147147
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
148+
compile "com.google.code.findbugs:jsr305:3.0.2"
148149
compile "com.sun.jersey:jersey-client:$jersey_version"
149150
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
150151
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"

modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ ext {
133133

134134
dependencies {
135135
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
136+
compile "com.google.code.findbugs:jsr305:3.0.2"
136137
compile "io.github.openfeign:feign-core:$feign_version"
137138
compile "io.github.openfeign:feign-jackson:$feign_version"
138139
compile "io.github.openfeign:feign-slf4j:$feign_version"

modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@
199199
<version>${swagger-annotations-version}</version>
200200
</dependency>
201201

202+
<!-- @Nullable annotation -->
203+
<dependency>
204+
<groupId>com.google.code.findbugs</groupId>
205+
<artifactId>jsr305</artifactId>
206+
<version>3.0.2</version>
207+
</dependency>
208+
202209
<!-- HTTP client: Netflix Feign -->
203210
<dependency>
204211
<groupId>io.github.openfeign</groupId>

modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ ext {
133133

134134
dependencies {
135135
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
136+
compile "com.google.code.findbugs:jsr305:3.0.2"
136137
compile "com.google.api-client:google-api-client:${google_api_client_version}"
137138
compile "org.glassfish.jersey.core:jersey-common:${jersey_common_version}"
138139
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"

modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@
219219
<artifactId>swagger-annotations</artifactId>
220220
<version>${swagger-annotations-version}</version>
221221
</dependency>
222+
<!-- @Nullable annotation -->
223+
<dependency>
224+
<groupId>com.google.code.findbugs</groupId>
225+
<artifactId>jsr305</artifactId>
226+
<version>3.0.2</version>
227+
</dependency>
222228
<!-- HTTP client: google-api-client -->
223229
<dependency>
224230
<groupId>com.google.api-client</groupId>

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ ext {
137137

138138
dependencies {
139139
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
140+
compile "com.google.code.findbugs:jsr305:3.0.2"
140141
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
141142
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
142143
compile "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@
229229
<version>${swagger-annotations-version}</version>
230230
</dependency>
231231

232+
<!-- @Nullable annotation -->
233+
<dependency>
234+
<groupId>com.google.code.findbugs</groupId>
235+
<artifactId>jsr305</artifactId>
236+
<version>3.0.2</version>
237+
</dependency>
238+
232239
<!-- HTTP client: jersey-client -->
233240
<dependency>
234241
<groupId>org.glassfish.jersey.core</groupId>

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ if(hasProperty('target') && target == 'android') {
127127

128128
dependencies {
129129
compile 'io.swagger:swagger-annotations:1.5.22'
130+
compile "com.google.code.findbugs:jsr305:3.0.2"
130131
compile 'com.squareup.okhttp3:okhttp:3.14.2'
131132
compile 'com.squareup.okhttp3:logging-interceptor:3.14.2'
132133
compile 'com.google.code.gson:gson:2.8.5'

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@
207207
<artifactId>swagger-annotations</artifactId>
208208
<version>${swagger-core-version}</version>
209209
</dependency>
210+
<!-- @Nullable annotation -->
211+
<dependency>
212+
<groupId>com.google.code.findbugs</groupId>
213+
<artifactId>jsr305</artifactId>
214+
<version>3.0.2</version>
215+
</dependency>
210216
<dependency>
211217
<groupId>com.squareup.okhttp3</groupId>
212218
<artifactId>okhttp</artifactId>

modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ ext {
111111

112112
dependencies {
113113
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
114+
compile "com.google.code.findbugs:jsr305:3.0.2"
114115
compile "io.rest-assured:scala-support:$rest_assured_version"
115116
compile "io.gsonfire:gson-fire:$gson_fire_version"
116117
{{#joda}}

modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@
206206
<artifactId>swagger-annotations</artifactId>
207207
<version>${swagger-annotations-version}</version>
208208
</dependency>
209+
<!-- @Nullable annotation -->
210+
<dependency>
211+
<groupId>com.google.code.findbugs</groupId>
212+
<artifactId>jsr305</artifactId>
213+
<version>3.0.2</version>
214+
</dependency>
209215
<dependency>
210216
<groupId>io.rest-assured</groupId>
211217
<artifactId>rest-assured</artifactId>

modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ ext {
135135

136136
dependencies {
137137
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
138+
compile "com.google.code.findbugs:jsr305:3.0.2"
138139
compile "org.jboss.resteasy:resteasy-client:$resteasy_version"
139140
compile "org.jboss.resteasy:resteasy-multipart-provider:$resteasy_version"
140141
compile "org.jboss.resteasy:resteasy-jackson2-provider:$resteasy_version"

modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@
179179
<artifactId>swagger-annotations</artifactId>
180180
<version>${swagger-annotations-version}</version>
181181
</dependency>
182+
<!-- @Nullable annotation -->
183+
<dependency>
184+
<groupId>com.google.code.findbugs</groupId>
185+
<artifactId>jsr305</artifactId>
186+
<version>3.0.2</version>
187+
</dependency>
182188
<!-- HTTP client: jersey-client -->
183189
<dependency>
184190
<groupId>org.jboss.resteasy</groupId>

modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ ext {
132132

133133
dependencies {
134134
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
135+
compile "com.google.code.findbugs:jsr305:3.0.2"
135136
compile "org.springframework:spring-web:$spring_web_version"
136137
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
137138
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"

modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@
219219
<artifactId>swagger-annotations</artifactId>
220220
<version>${swagger-annotations-version}</version>
221221
</dependency>
222+
223+
<!-- @Nullable annotation -->
224+
<dependency>
225+
<groupId>com.google.code.findbugs</groupId>
226+
<artifactId>jsr305</artifactId>
227+
<version>3.0.2</version>
228+
</dependency>
222229

223230
<!-- HTTP client: Spring RestTemplate -->
224231
<dependency>

modules/openapi-generator/src/main/resources/Java/libraries/retrofit/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ ext {
120120

121121
dependencies {
122122
compile "com.squareup.okhttp:okhttp:$okhttp_version"
123+
compile "com.google.code.findbugs:jsr305:3.0.2"
123124
compile "com.squareup.retrofit:retrofit:$retrofit_version"
124125
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
125126
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"

modules/openapi-generator/src/main/resources/Java/libraries/retrofit/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@
219219
<artifactId>swagger-annotations</artifactId>
220220
<version>${swagger-annotations-version}</version>
221221
</dependency>
222+
<!-- @Nullable annotation -->
223+
<dependency>
224+
<groupId>com.google.code.findbugs</groupId>
225+
<artifactId>jsr305</artifactId>
226+
<version>3.0.2</version>
227+
</dependency>
222228
<dependency>
223229
<groupId>com.squareup.retrofit</groupId>
224230
<artifactId>retrofit</artifactId>

modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ dependencies {
166166
compile "io.reactivex.rxjava2:rxjava:$rx_java_version"
167167
{{/useRxJava2}}
168168
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
169+
compile "com.google.code.findbugs:jsr305:3.0.2"
169170
compile ("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"){
170171
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
171172
}

modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@
198198
<artifactId>swagger-annotations</artifactId>
199199
<version>${swagger-annotations-version}</version>
200200
</dependency>
201+
<!-- @Nullable annotation -->
202+
<dependency>
203+
<groupId>com.google.code.findbugs</groupId>
204+
<artifactId>jsr305</artifactId>
205+
<version>3.0.2</version>
206+
</dependency>
201207
<dependency>
202208
<groupId>com.squareup.retrofit2</groupId>
203209
<artifactId>converter-gson</artifactId>

modules/openapi-generator/src/main/resources/Java/libraries/vertx/build.gradle.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ext {
3636

3737
dependencies {
3838
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
39+
compile "com.google.code.findbugs:jsr305:3.0.2"
3940
compile "io.vertx:vertx-web-client:$vertx_version"
4041
compile "io.vertx:vertx-rx-java:$vertx_version"
4142
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"

modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@
208208
<version>${swagger-annotations-version}</version>
209209
</dependency>
210210

211+
<!-- @Nullable annotation -->
212+
<dependency>
213+
<groupId>com.google.code.findbugs</groupId>
214+
<artifactId>jsr305</artifactId>
215+
<version>3.0.2</version>
216+
</dependency>
217+
211218
<!-- Vertx -->
212219
<dependency>
213220
<groupId>io.vertx</groupId>

modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
<artifactId>swagger-annotations</artifactId>
7373
<version>${swagger-annotations-version}</version>
7474
</dependency>
75+
76+
<!-- @Nullable annotation -->
77+
<dependency>
78+
<groupId>com.google.code.findbugs</groupId>
79+
<artifactId>jsr305</artifactId>
80+
<version>3.0.2</version>
81+
</dependency>
7582

7683
<dependency>
7784
<groupId>io.projectreactor</groupId>

modules/openapi-generator/src/main/resources/Java/pojo.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
129129
{{/maximum}}
130130
* @return {{name}}
131131
**/
132+
{{^required}} @javax.annotation.Nullable {{/required}}
132133
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
133134
{{#vendorExtensions.extraAnnotation}}
134135
{{{vendorExtensions.extraAnnotation}}}

modules/openapi-generator/src/main/resources/Java/pom.mustache

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@
220220
<version>${swagger-annotations-version}</version>
221221
</dependency>
222222

223+
<!-- @Nullable annotation -->
224+
<dependency>
225+
<groupId>com.google.code.findbugs</groupId>
226+
<artifactId>jsr305</artifactId>
227+
<version>3.0.2</version>
228+
</dependency>
229+
230+
223231
<!-- HTTP client: jersey-client -->
224232
<dependency>
225233
<groupId>com.sun.jersey</groupId>

modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/pom.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@
7777
<version>[1.5.3,1.5.16]</version>
7878
</dependency>
7979

80+
<!-- @Nullable annotation -->
81+
<dependency>
82+
<groupId>com.google.code.findbugs</groupId>
83+
<artifactId>jsr305</artifactId>
84+
<version>3.0.2</version>
85+
</dependency>
86+
8087
{{#useBeanValidation}}
8188
<!-- Bean Validation API support -->
8289
<dependency>

modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
<artifactId>swagger-annotations</artifactId>
7272
<version>${swagger-core-version}</version>
7373
</dependency>
74+
<!-- @Nullable annotation -->
75+
<dependency>
76+
<groupId>com.google.code.findbugs</groupId>
77+
<artifactId>jsr305</artifactId>
78+
<version>3.0.2</version>
79+
</dependency>
7480
<dependency>
7581
<groupId>org.slf4j</groupId>
7682
<artifactId>slf4j-log4j12</artifactId>

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
<version>1.5.3</version>
8989
</dependency>
9090
{{/useSwaggerAnnotations}}
91+
<!-- @Nullable annotation -->
92+
<dependency>
93+
<groupId>com.google.code.findbugs</groupId>
94+
<artifactId>jsr305</artifactId>
95+
<version>3.0.2</version>
96+
</dependency>
9197
<dependency>
9298
<groupId>junit</groupId>
9399
<artifactId>junit</artifactId>

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@
111111
<artifactId>swagger-annotations</artifactId>
112112
<version>1.5.14</version>
113113
</dependency>
114+
<!-- @Nullable annotation -->
115+
<dependency>
116+
<groupId>com.google.code.findbugs</groupId>
117+
<artifactId>jsr305</artifactId>
118+
<version>3.0.2</version>
119+
</dependency>
114120
<dependency>
115121
<groupId>com.fasterxml.jackson.dataformat</groupId>
116122
<artifactId>jackson-dataformat-yaml</artifactId>

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
<artifactId>swagger-annotations</artifactId>
4848
<version>${swagger-core-version}</version>
4949
</dependency>
50+
<!-- @Nullable annotation -->
51+
<dependency>
52+
<groupId>com.google.code.findbugs</groupId>
53+
<artifactId>jsr305</artifactId>
54+
<version>3.0.2</version>
55+
</dependency>
5056
<dependency>
5157
<groupId>org.springframework.cloud</groupId>
5258
<artifactId>spring-cloud-starter-openfeign</artifactId>

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@
177177
<artifactId>swagger-annotations</artifactId>
178178
<version>1.5.14</version>
179179
</dependency>
180+
<!-- @Nullable annotation -->
181+
<dependency>
182+
<groupId>com.google.code.findbugs</groupId>
183+
<artifactId>jsr305</artifactId>
184+
<version>3.0.2</version>
185+
</dependency>
180186
<dependency>
181187
<groupId>com.fasterxml.jackson.dataformat</groupId>
182188
<artifactId>jackson-dataformat-yaml</artifactId>

modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
<artifactId>swagger-annotations</artifactId>
1212
<version>${swagger-annotations-version}</version>
1313
</dependency>
14+
<!-- @Nullable annotation -->
15+
<dependency>
16+
<groupId>com.google.code.findbugs</groupId>
17+
<artifactId>jsr305</artifactId>
18+
<version>3.0.2</version>
19+
</dependency>
1420
<dependency>
1521
<groupId>org.apache.httpcomponents</groupId>
1622
<artifactId>httpcore</artifactId>

modules/openapi-generator/src/main/resources/android/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@
131131
<artifactId>swagger-annotations</artifactId>
132132
<version>${swagger-core-version}</version>
133133
</dependency>
134+
<!-- @Nullable annotation -->
135+
<dependency>
136+
<groupId>com.google.code.findbugs</groupId>
137+
<artifactId>jsr305</artifactId>
138+
<version>3.0.2</version>
139+
</dependency>
134140
<dependency>
135141
<groupId>com.google.code.gson</groupId>
136142
<artifactId>gson</artifactId>

modules/openapi-generator/src/main/resources/java-undertow-server/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@
108108
<artifactId>swagger-annotations</artifactId>
109109
<version>${version.swagger}</version>
110110
</dependency>
111+
<!-- @Nullable annotation -->
112+
<dependency>
113+
<groupId>com.google.code.findbugs</groupId>
114+
<artifactId>jsr305</artifactId>
115+
<version>3.0.2</version>
116+
</dependency>
111117

112118
<!-- Test Dependencies -->
113119
<dependency>

modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
<version>1.5.21</version>
106106
</dependency>
107107
{{/swaggerAnnotations}}
108+
<!-- @Nullable annotation -->
109+
<dependency>
110+
<groupId>com.google.code.findbugs</groupId>
111+
<artifactId>jsr305</artifactId>
112+
<version>3.0.2</version>
113+
</dependency>
108114
<dependency>
109115
<groupId>com.fasterxml.jackson.dataformat</groupId>
110116
<artifactId>jackson-dataformat-yaml</artifactId>

0 commit comments

Comments
 (0)