fix: honor required fields in jackson @JsonProperty annotations (#21876)

* fix: honor required fields in jackson @JsonProperty annotations

* add samples

* fix: trigger build

* fix: undo

* update to handle nullable as well

---------

Co-authored-by: Erik Lagerholm <erik.lagerholm@volvocars.com>
This commit is contained in:
William Cheng
2025-09-03 16:41:59 +08:00
committed by GitHub
parent babb3e272b
commit 6e443f1354
1415 changed files with 8393 additions and 8393 deletions

View File

@@ -60,14 +60,14 @@ public class Bird {
* @return size
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SIZE)
@JsonProperty(value = JSON_PROPERTY_SIZE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getSize() {
return size;
}
@JsonProperty(JSON_PROPERTY_SIZE)
@JsonProperty(value = JSON_PROPERTY_SIZE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSize(@javax.annotation.Nullable String size) {
this.size = size;
@@ -84,14 +84,14 @@ public class Bird {
* @return color
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_COLOR)
@JsonProperty(value = JSON_PROPERTY_COLOR, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getColor() {
return color;
}
@JsonProperty(JSON_PROPERTY_COLOR)
@JsonProperty(value = JSON_PROPERTY_COLOR, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setColor(@javax.annotation.Nullable String color) {
this.color = color;

View File

@@ -60,14 +60,14 @@ public class Category {
* @return id
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(@javax.annotation.Nullable Long id) {
this.id = id;
@@ -84,14 +84,14 @@ public class Category {
* @return name
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(@javax.annotation.Nullable String name) {
this.name = name;

View File

@@ -69,14 +69,14 @@ public class DataQuery extends Query {
* @return suffix
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SUFFIX)
@JsonProperty(value = JSON_PROPERTY_SUFFIX, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getSuffix() {
return suffix;
}
@JsonProperty(JSON_PROPERTY_SUFFIX)
@JsonProperty(value = JSON_PROPERTY_SUFFIX, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSuffix(@javax.annotation.Nullable String suffix) {
this.suffix = suffix;
@@ -93,14 +93,14 @@ public class DataQuery extends Query {
* @return text
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_TEXT)
@JsonProperty(value = JSON_PROPERTY_TEXT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getText() {
return text;
}
@JsonProperty(JSON_PROPERTY_TEXT)
@JsonProperty(value = JSON_PROPERTY_TEXT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setText(@javax.annotation.Nullable String text) {
this.text = text;
@@ -117,14 +117,14 @@ public class DataQuery extends Query {
* @return date
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DATE)
@JsonProperty(value = JSON_PROPERTY_DATE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Instant getDate() {
return date;
}
@JsonProperty(JSON_PROPERTY_DATE)
@JsonProperty(value = JSON_PROPERTY_DATE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDate(@javax.annotation.Nullable Instant date) {
this.date = date;

View File

@@ -139,14 +139,14 @@ public class DefaultValue {
* @return arrayStringEnumRefDefault
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<StringEnumRef> getArrayStringEnumRefDefault() {
return arrayStringEnumRefDefault;
}
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayStringEnumRefDefault(@javax.annotation.Nullable List<StringEnumRef> arrayStringEnumRefDefault) {
this.arrayStringEnumRefDefault = arrayStringEnumRefDefault;
@@ -171,14 +171,14 @@ public class DefaultValue {
* @return arrayStringEnumDefault
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
return arrayStringEnumDefault;
}
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayStringEnumDefault(@javax.annotation.Nullable List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
this.arrayStringEnumDefault = arrayStringEnumDefault;
@@ -203,14 +203,14 @@ public class DefaultValue {
* @return arrayStringDefault
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getArrayStringDefault() {
return arrayStringDefault;
}
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayStringDefault(@javax.annotation.Nullable List<String> arrayStringDefault) {
this.arrayStringDefault = arrayStringDefault;
@@ -235,14 +235,14 @@ public class DefaultValue {
* @return arrayIntegerDefault
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_INTEGER_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<Integer> getArrayIntegerDefault() {
return arrayIntegerDefault;
}
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
@JsonProperty(value = JSON_PROPERTY_ARRAY_INTEGER_DEFAULT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayIntegerDefault(@javax.annotation.Nullable List<Integer> arrayIntegerDefault) {
this.arrayIntegerDefault = arrayIntegerDefault;
@@ -267,14 +267,14 @@ public class DefaultValue {
* @return arrayString
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getArrayString() {
return arrayString;
}
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArrayString(@javax.annotation.Nullable List<String> arrayString) {
this.arrayString = arrayString;
@@ -308,7 +308,7 @@ public class DefaultValue {
return arrayStringNullable.orElse(null);
}
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_NULLABLE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public JsonNullable<List<String>> getArrayStringNullable_JsonNullable() {
@@ -352,7 +352,7 @@ public class DefaultValue {
return arrayStringExtensionNullable.orElse(null);
}
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_EXTENSION_NULLABLE)
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_EXTENSION_NULLABLE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public JsonNullable<List<String>> getArrayStringExtensionNullable_JsonNullable() {
@@ -384,7 +384,7 @@ public class DefaultValue {
return stringNullable.orElse(null);
}
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
@JsonProperty(value = JSON_PROPERTY_STRING_NULLABLE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public JsonNullable<String> getStringNullable_JsonNullable() {

View File

@@ -66,14 +66,14 @@ public class NumberPropertiesOnly {
* @return number
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NUMBER)
@JsonProperty(value = JSON_PROPERTY_NUMBER, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getNumber() {
return number;
}
@JsonProperty(JSON_PROPERTY_NUMBER)
@JsonProperty(value = JSON_PROPERTY_NUMBER, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setNumber(@javax.annotation.Nullable BigDecimal number) {
this.number = number;
@@ -90,14 +90,14 @@ public class NumberPropertiesOnly {
* @return _float
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_FLOAT)
@JsonProperty(value = JSON_PROPERTY_FLOAT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Float getFloat() {
return _float;
}
@JsonProperty(JSON_PROPERTY_FLOAT)
@JsonProperty(value = JSON_PROPERTY_FLOAT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFloat(@javax.annotation.Nullable Float _float) {
this._float = _float;
@@ -116,14 +116,14 @@ public class NumberPropertiesOnly {
* @return _double
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DOUBLE)
@JsonProperty(value = JSON_PROPERTY_DOUBLE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Double getDouble() {
return _double;
}
@JsonProperty(JSON_PROPERTY_DOUBLE)
@JsonProperty(value = JSON_PROPERTY_DOUBLE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDouble(@javax.annotation.Nullable Double _double) {
this._double = _double;

View File

@@ -121,14 +121,14 @@ public class Pet {
* @return id
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(@javax.annotation.Nullable Long id) {
this.id = id;
@@ -145,14 +145,14 @@ public class Pet {
* @return name
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setName(@javax.annotation.Nonnull String name) {
this.name = name;
@@ -169,14 +169,14 @@ public class Pet {
* @return category
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_CATEGORY)
@JsonProperty(value = JSON_PROPERTY_CATEGORY, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Category getCategory() {
return category;
}
@JsonProperty(JSON_PROPERTY_CATEGORY)
@JsonProperty(value = JSON_PROPERTY_CATEGORY, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setCategory(@javax.annotation.Nullable Category category) {
this.category = category;
@@ -201,14 +201,14 @@ public class Pet {
* @return photoUrls
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_PHOTO_URLS)
@JsonProperty(value = JSON_PROPERTY_PHOTO_URLS, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public List<String> getPhotoUrls() {
return photoUrls;
}
@JsonProperty(JSON_PROPERTY_PHOTO_URLS)
@JsonProperty(value = JSON_PROPERTY_PHOTO_URLS, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setPhotoUrls(@javax.annotation.Nonnull List<String> photoUrls) {
this.photoUrls = photoUrls;
@@ -233,14 +233,14 @@ public class Pet {
* @return tags
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonProperty(value = JSON_PROPERTY_TAGS, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<Tag> getTags() {
return tags;
}
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonProperty(value = JSON_PROPERTY_TAGS, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setTags(@javax.annotation.Nullable List<Tag> tags) {
this.tags = tags;
@@ -257,14 +257,14 @@ public class Pet {
* @return status
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_STATUS)
@JsonProperty(value = JSON_PROPERTY_STATUS, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public StatusEnum getStatus() {
return status;
}
@JsonProperty(JSON_PROPERTY_STATUS)
@JsonProperty(value = JSON_PROPERTY_STATUS, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setStatus(@javax.annotation.Nullable StatusEnum status) {
this.status = status;

View File

@@ -99,14 +99,14 @@ public class Query {
* @return id
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(@javax.annotation.Nullable Long id) {
this.id = id;
@@ -131,14 +131,14 @@ public class Query {
* @return outcomes
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_OUTCOMES)
@JsonProperty(value = JSON_PROPERTY_OUTCOMES, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<OutcomesEnum> getOutcomes() {
return outcomes;
}
@JsonProperty(JSON_PROPERTY_OUTCOMES)
@JsonProperty(value = JSON_PROPERTY_OUTCOMES, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setOutcomes(@javax.annotation.Nullable List<OutcomesEnum> outcomes) {
this.outcomes = outcomes;

View File

@@ -60,14 +60,14 @@ public class Tag {
* @return id
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(@javax.annotation.Nullable Long id) {
this.id = id;
@@ -84,14 +84,14 @@ public class Tag {
* @return name
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(@javax.annotation.Nullable String name) {
this.name = name;

View File

@@ -55,14 +55,14 @@ public class TestFormObjectMultipartRequestMarker {
* @return name
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(@javax.annotation.Nullable String name) {
this.name = name;

View File

@@ -70,14 +70,14 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
* @return size
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SIZE)
@JsonProperty(value = JSON_PROPERTY_SIZE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getSize() {
return size;
}
@JsonProperty(JSON_PROPERTY_SIZE)
@JsonProperty(value = JSON_PROPERTY_SIZE, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSize(@javax.annotation.Nullable String size) {
this.size = size;
@@ -94,14 +94,14 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
* @return color
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_COLOR)
@JsonProperty(value = JSON_PROPERTY_COLOR, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getColor() {
return color;
}
@JsonProperty(JSON_PROPERTY_COLOR)
@JsonProperty(value = JSON_PROPERTY_COLOR, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setColor(@javax.annotation.Nullable String color) {
this.color = color;
@@ -118,14 +118,14 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
* @return id
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(@javax.annotation.Nullable Long id) {
this.id = id;
@@ -142,14 +142,14 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
* @return name
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonProperty(value = JSON_PROPERTY_NAME, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setName(@javax.annotation.Nullable String name) {
this.name = name;

View File

@@ -65,14 +65,14 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
* @return values
*/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_VALUES)
@JsonProperty(value = JSON_PROPERTY_VALUES, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getValues() {
return values;
}
@JsonProperty(JSON_PROPERTY_VALUES)
@JsonProperty(value = JSON_PROPERTY_VALUES, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setValues(@javax.annotation.Nullable List<String> values) {
this.values = values;