Skip to content

Commit d46ba8b

Browse files
authored
Merge pull request #8809 from cognifloyd/nullable-3.0.0
Add nullable property support from OAS 3.0 spec
2 parents 9d3f7f1 + 87bbff1 commit d46ba8b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/CodegenParameter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class CodegenParameter extends CodegenObject {
1616
public List<String> _enum;
1717
public Map<String, Object> allowableValues;
1818
public CodegenProperty items;
19+
public boolean nullable;
1920

2021
/**
2122
* Determines whether this parameter is mandatory. If the parameter is in "path",
@@ -106,6 +107,7 @@ public CodegenParameter copy() {
106107
output.description = this.description;
107108
output.unescapedDescription = this.unescapedDescription;
108109
output.baseType = this.baseType;
110+
output.nullable = this.nullable;
109111
output.required = this.required;
110112
output.maximum = this.maximum;
111113
output.exclusiveMaximum = this.exclusiveMaximum;
@@ -186,6 +188,8 @@ public boolean equals(Object o) {
186188
return false;
187189
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
188190
return false;
191+
if (nullable != that.nullable)
192+
return false;
189193
if (required != that.required)
190194
return false;
191195
if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null)
@@ -232,6 +236,7 @@ public int hashCode() {
232236
result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0);
233237
result = 31 * result + (items != null ? items.hashCode() : 0);
234238
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
239+
result = 31 * result + (nullable ? 13:31);
235240
result = 31 * result + (required ? 13:31);
236241
result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
237242
result = 31 * result + (exclusiveMaximum ? 13:31);
@@ -323,6 +328,10 @@ public CodegenProperty getItems() {
323328
return items;
324329
}
325330

331+
public boolean getNullable() {
332+
return nullable;
333+
}
334+
326335
public boolean getRequired() {
327336
return required;
328337
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/CodegenProperty.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class CodegenProperty extends CodegenObject implements Cloneable {
3737
public boolean exclusiveMinimum;
3838
public boolean exclusiveMaximum;
3939
public boolean required, secondaryParam;
40+
public boolean nullable;
4041

4142
public List<String> _enum;
4243
public Map<String, Object> allowableValues;
@@ -279,6 +280,14 @@ public void setSecondaryParam(boolean secondaryParam) {
279280
this.secondaryParam = secondaryParam;
280281
}
281282

283+
public boolean getNullable() {
284+
return nullable;
285+
}
286+
287+
public void setNullable(boolean nullable) {
288+
this.nullable = nullable;
289+
}
290+
282291
public List<String> get_enum() {
283292
return _enum;
284293
}
@@ -403,6 +412,7 @@ public int hashCode()
403412
result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
404413
result = prime * result + ((required ? 13:31));
405414
result = prime * result + ((secondaryParam ? 13:31));
415+
result = prime * result + ((nullable ? 13:31));
406416
result = prime * result + ((setter == null) ? 0 : setter.hashCode());
407417
result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode());
408418
result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode());
@@ -503,6 +513,9 @@ public boolean equals(Object obj) {
503513
if (this.secondaryParam != other.secondaryParam) {
504514
return false;
505515
}
516+
if (this.nullable != other.nullable) {
517+
return false;
518+
}
506519
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
507520
return false;
508521
}

0 commit comments

Comments
 (0)