Skip to content

Conversation

@jpfinne
Copy link
Contributor

@jpfinne jpfinne commented Jan 26, 2026

Improve the generated Spring constructors by adding @JsonProperty and @NullUnmarked when JSpecify is used)

Prepare for Spring-boot 4 with JSpecify partial support.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)

Fixes #22843

Partially fixes #22757

  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08)


Summary by cubic

Adds Jackson annotations to generated Spring model constructors so Jackson can use property-based deserialization. Applies to all-args or required-args constructors when Jackson is enabled, and skips XML.

  • New Features
    • Add @JsonCreator(mode = PROPERTIES) to all-args constructors when x-java-all-args-constructor is used.
    • Add @JsonCreator and @JsonProperty to required-args constructors when all fields are required and no all-args constructor exists.
    • Annotate constructor parameters with @JsonProperty for correct field names, including nullable and container types.
    • Update pojo.mustache, SpringCodegen, tests, and regenerate samples; no annotations added when withXml is true; add optional JSpecify nullness support and a sample project.

Written for commit acd89a3. Summary will update on new commits.

@jpfinne jpfinne changed the title Feature/json property in all args constructor [Spring] constructor improvements (@JsonProperty, JSpecify support) Jan 28, 2026
@jpfinne jpfinne marked this pull request as ready for review January 28, 2026 17:05
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 issues found across 122 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Animal.java">

<violation number="1" location="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Animal.java:58">
P2: Property-based @JsonCreator will receive null for missing optional properties and the constructor assigns it directly, overriding the field’s default value ("red"). Deserializing JSON without `color` will now set `color` to null instead of keeping the default, changing behavior from the previous setter-based path.</violation>
</file>

<file name="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java">

<violation number="1" location="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java:47">
P2: @JsonCreator property-based constructor can overwrite non-null list defaults with null when JSON omits fields, changing behavior from empty lists to null.</violation>
</file>

<file name="samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/TypeHolderDefault.java">

<violation number="1" location="samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/TypeHolderDefault.java:46">
P2: @JsonCreator property-based constructor will receive null for missing JSON properties, so this change overwrites default field initializers with nulls and can violate @NotNull/default-value expectations.</violation>
</file>

<file name="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java">

<violation number="1" location="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java:43">
P2: @JsonCreator constructor can overwrite the default non-null list with null when "files" is omitted, changing deserialization to allow null collections.</violation>
</file>

<file name="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java">

<violation number="1" location="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java:70">
P2: @JsonCreator deserialization overwrites default empty maps with null when properties are absent</violation>

<violation number="2" location="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java:71">
P2: JsonCreator now forces missing anytype_2 to JsonNullable.of(null), losing undefined vs null distinction</violation>
</file>

<file name="samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java">

<violation number="1" location="samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java:49">
P2: @JsonCreator constructor overwrites the default `arrayItem` initialization; when `array_item` is omitted, Jackson passes null and the list becomes null, violating the non-null contract.</violation>
</file>

<file name="samples/openapi3/server/petstore/spring-boot-oneof-interface/src/main/java/org/openapitools/model/Banana.java">

<violation number="1" location="samples/openapi3/server/petstore/spring-boot-oneof-interface/src/main/java/org/openapitools/model/Banana.java:41">
P2: @JsonCreator constructor lacks a fruitType parameter, so fruitType remains null due to self-assignment, violating required discriminator field.</violation>
</file>

<file name="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java">

<violation number="1" location="samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java:40">
P2: @JsonCreator constructor overwrites the default empty list with null when the JSON omits ArrayArrayNumber, altering deserialization semantics for optional properties.</violation>
</file>

<file name="samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/TypeHolderExample.java">

<violation number="1" location="samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/TypeHolderExample.java:47">
P2: @JsonCreator constructor can override the default non-null list with null when array_item is missing, violating the @NotNull contract for arrayItem.</violation>
</file>

<file name="samples/openapi3/server/petstore/springboot-jspecify/src/main/java/org/openapitools/model/Pet.java">

<violation number="1" location="samples/openapi3/server/petstore/springboot-jspecify/src/main/java/org/openapitools/model/Pet.java:95">
P2: Property-based @JsonCreator overwrites list defaults with null for missing JSON properties, making photoUrls/tags nullable and violating the non-null expectations.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +58 to 61
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Animal(@JsonProperty("className") String className, @JsonProperty("color") String color) {
this.className = className;
this.color = color;
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Property-based @JsonCreator will receive null for missing optional properties and the constructor assigns it directly, overriding the field’s default value ("red"). Deserializing JSON without color will now set color to null instead of keeping the default, changing behavior from the previous setter-based path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/Animal.java, line 58:

<comment>Property-based @JsonCreator will receive null for missing optional properties and the constructor assigns it directly, overriding the field’s default value ("red"). Deserializing JSON without `color` will now set `color` to null instead of keeping the default, changing behavior from the previous setter-based path.</comment>

<file context>
@@ -55,7 +55,8 @@ public Animal(String className) {
    * Constructor with all args parameters
    */
-  public Animal(String className, String color) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public Animal(@JsonProperty("className") String className, @JsonProperty("color") String color) {
       this.className = className;
</file context>
Suggested change
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Animal(@JsonProperty("className") String className, @JsonProperty("color") String color) {
this.className = className;
this.color = color;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Animal(@JsonProperty("className") String className, @JsonProperty("color") String color) {
this.className = className;
this.color = color != null ? color : "red";
}
Fix with Cubic

Comment on lines +47 to 50
public ArrayTest(@JsonProperty("array_of_string") List<String> arrayOfString, @JsonProperty("array_array_of_integer") List<List<Long>> arrayArrayOfInteger, @JsonProperty("array_array_of_model") List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
this.arrayOfString = arrayOfString;
this.arrayArrayOfInteger = arrayArrayOfInteger;
this.arrayArrayOfModel = arrayArrayOfModel;
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator property-based constructor can overwrite non-null list defaults with null when JSON omits fields, changing behavior from empty lists to null.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayTest.java, line 47:

<comment>@JsonCreator property-based constructor can overwrite non-null list defaults with null when JSON omits fields, changing behavior from empty lists to null.</comment>

<file context>
@@ -43,7 +43,8 @@ public ArrayTest() {
    */
-  public ArrayTest(List<String> arrayOfString, List<List<Long>> arrayArrayOfInteger, List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public ArrayTest(@JsonProperty("array_of_string") List<String> arrayOfString, @JsonProperty("array_array_of_integer") List<List<Long>> arrayArrayOfInteger, @JsonProperty("array_array_of_model") List<List<@Valid ReadOnlyFirst>> arrayArrayOfModel) {
       this.arrayOfString = arrayOfString;
       this.arrayArrayOfInteger = arrayArrayOfInteger;
</file context>
Fix with Cubic

Comment on lines +46 to 49
public TypeHolderDefault(@JsonProperty("string_item") String stringItem, @JsonProperty("number_item") BigDecimal numberItem, @JsonProperty("integer_item") Integer integerItem, @JsonProperty("bool_item") Boolean boolItem, @JsonProperty("array_item") List<Integer> arrayItem) {
this.stringItem = stringItem;
this.numberItem = numberItem;
this.integerItem = integerItem;
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator property-based constructor will receive null for missing JSON properties, so this change overwrites default field initializers with nulls and can violate @NotNull/default-value expectations.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/TypeHolderDefault.java, line 46:

<comment>@JsonCreator property-based constructor will receive null for missing JSON properties, so this change overwrites default field initializers with nulls and can violate @NotNull/default-value expectations.</comment>

<file context>
@@ -42,7 +42,8 @@ public TypeHolderDefault() {
    */
-  public TypeHolderDefault(String stringItem, BigDecimal numberItem, Integer integerItem, Boolean boolItem, List<Integer> arrayItem) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public TypeHolderDefault(@JsonProperty("string_item") String stringItem, @JsonProperty("number_item") BigDecimal numberItem, @JsonProperty("integer_item") Integer integerItem, @JsonProperty("bool_item") Boolean boolItem, @JsonProperty("array_item") List<Integer> arrayItem) {
     this.stringItem = stringItem;
     this.numberItem = numberItem;
</file context>
Fix with Cubic

Comment on lines +43 to 46
public FileSchemaTestClass(@JsonProperty("file") @Nullable File file, @JsonProperty("files") List<@Valid File> files) {
this.file = file;
this.files = files;
}
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator constructor can overwrite the default non-null list with null when "files" is omitted, changing deserialization to allow null collections.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/FileSchemaTestClass.java, line 43:

<comment>@JsonCreator constructor can overwrite the default non-null list with null when "files" is omitted, changing deserialization to allow null collections.</comment>

<file context>
@@ -39,7 +39,8 @@ public FileSchemaTestClass() {
    */
-  public FileSchemaTestClass(@Nullable File file, List<@Valid File> files) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public FileSchemaTestClass(@JsonProperty("file") @Nullable File file, @JsonProperty("files") List<@Valid File> files) {
       this.file = file;
       this.files = files;
</file context>
Suggested change
public FileSchemaTestClass(@JsonProperty("file") @Nullable File file, @JsonProperty("files") List<@Valid File> files) {
this.file = file;
this.files = files;
}
public FileSchemaTestClass(@JsonProperty("file") @Nullable File file, @JsonProperty("files") List<@Valid File> files) {
this.file = file;
this.files = files == null ? new ArrayList<>() : files;
}
Fix with Cubic

*/
public AdditionalPropertiesClass(Map<String, String> mapString, Map<String, BigDecimal> mapNumber, Map<String, Integer> mapInteger, Map<String, Boolean> mapBoolean, Map<String, List<Integer>> mapArrayInteger, Map<String, List<Object>> mapArrayAnytype, Map<String, Map<String, String>> mapMapString, Map<String, Map<String, Object>> mapMapAnytype, @Nullable Object anytype1, Object anytype2, @Nullable Object anytype3) {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public AdditionalPropertiesClass(@JsonProperty("map_string") Map<String, String> mapString, @JsonProperty("map_number") Map<String, BigDecimal> mapNumber, @JsonProperty("map_integer") Map<String, Integer> mapInteger, @JsonProperty("map_boolean") Map<String, Boolean> mapBoolean, @JsonProperty("map_array_integer") Map<String, List<Integer>> mapArrayInteger, @JsonProperty("map_array_anytype") Map<String, List<Object>> mapArrayAnytype, @JsonProperty("map_map_string") Map<String, Map<String, String>> mapMapString, @JsonProperty("map_map_anytype") Map<String, Map<String, Object>> mapMapAnytype, @JsonProperty("anytype_1") @Nullable Object anytype1, @JsonProperty("anytype_2") Object anytype2, @JsonProperty("anytype_3") @Nullable Object anytype3) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: JsonCreator now forces missing anytype_2 to JsonNullable.of(null), losing undefined vs null distinction

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java, line 71:

<comment>JsonCreator now forces missing anytype_2 to JsonNullable.of(null), losing undefined vs null distinction</comment>

<file context>
@@ -67,7 +67,8 @@ public AdditionalPropertiesClass() {
    */
-  public AdditionalPropertiesClass(Map<String, String> mapString, Map<String, BigDecimal> mapNumber, Map<String, Integer> mapInteger, Map<String, Boolean> mapBoolean, Map<String, List<Integer>> mapArrayInteger, Map<String, List<Object>> mapArrayAnytype, Map<String, Map<String, String>> mapMapString, Map<String, Map<String, Object>> mapMapAnytype, @Nullable Object anytype1, Object anytype2, @Nullable Object anytype3) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public AdditionalPropertiesClass(@JsonProperty("map_string") Map<String, String> mapString, @JsonProperty("map_number") Map<String, BigDecimal> mapNumber, @JsonProperty("map_integer") Map<String, Integer> mapInteger, @JsonProperty("map_boolean") Map<String, Boolean> mapBoolean, @JsonProperty("map_array_integer") Map<String, List<Integer>> mapArrayInteger, @JsonProperty("map_array_anytype") Map<String, List<Object>> mapArrayAnytype, @JsonProperty("map_map_string") Map<String, Map<String, String>> mapMapString, @JsonProperty("map_map_anytype") Map<String, Map<String, Object>> mapMapAnytype, @JsonProperty("anytype_1") @Nullable Object anytype1, @JsonProperty("anytype_2") Object anytype2, @JsonProperty("anytype_3") @Nullable Object anytype3) {
       this.mapString = mapString;
       this.mapNumber = mapNumber;
</file context>
Fix with Cubic

Comment on lines +49 to 53
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public TypeHolderExample(@JsonProperty("string_item") String stringItem, @JsonProperty("number_item") BigDecimal numberItem, @JsonProperty("float_item") Float floatItem, @JsonProperty("integer_item") Integer integerItem, @JsonProperty("bool_item") Boolean boolItem, @JsonProperty("array_item") List<Integer> arrayItem) {
this.stringItem = stringItem;
this.numberItem = numberItem;
this.floatItem = floatItem;
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator constructor overwrites the default arrayItem initialization; when array_item is omitted, Jackson passes null and the list becomes null, violating the non-null contract.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/TypeHolderExample.java, line 49:

<comment>@JsonCreator constructor overwrites the default `arrayItem` initialization; when `array_item` is omitted, Jackson passes null and the list becomes null, violating the non-null contract.</comment>

<file context>
@@ -46,7 +46,8 @@ public TypeHolderExample() {
    * Constructor with only required parameters
    */
-  public TypeHolderExample(String stringItem, BigDecimal numberItem, Float floatItem, Integer integerItem, Boolean boolItem, List<Integer> arrayItem) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public TypeHolderExample(@JsonProperty("string_item") String stringItem, @JsonProperty("number_item") BigDecimal numberItem, @JsonProperty("float_item") Float floatItem, @JsonProperty("integer_item") Integer integerItem, @JsonProperty("bool_item") Boolean boolItem, @JsonProperty("array_item") List<Integer> arrayItem) {
     this.stringItem = stringItem;
</file context>
Fix with Cubic

*/
public Banana(Integer length) {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Banana(@JsonProperty("length") Integer length) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator constructor lacks a fruitType parameter, so fruitType remains null due to self-assignment, violating required discriminator field.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/server/petstore/spring-boot-oneof-interface/src/main/java/org/openapitools/model/Banana.java, line 41:

<comment>@JsonCreator constructor lacks a fruitType parameter, so fruitType remains null due to self-assignment, violating required discriminator field.</comment>

<file context>
@@ -37,7 +37,8 @@ public Banana() {
    */
-  public Banana(Integer length) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public Banana(@JsonProperty("length") Integer length) {
     this.length = length;
     this.fruitType = fruitType;
</file context>
Fix with Cubic

Comment on lines +40 to 43
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public ArrayOfArrayOfNumberOnly(@JsonProperty("ArrayArrayNumber") List<List<BigDecimal>> arrayArrayNumber) {
this.arrayArrayNumber = arrayArrayNumber;
}
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator constructor overwrites the default empty list with null when the JSON omits ArrayArrayNumber, altering deserialization semantics for optional properties.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java, line 40:

<comment>@JsonCreator constructor overwrites the default empty list with null when the JSON omits ArrayArrayNumber, altering deserialization semantics for optional properties.</comment>

<file context>
@@ -37,7 +37,8 @@ public ArrayOfArrayOfNumberOnly() {
    * Constructor with all args parameters
    */
-  public ArrayOfArrayOfNumberOnly(List<List<BigDecimal>> arrayArrayNumber) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public ArrayOfArrayOfNumberOnly(@JsonProperty("ArrayArrayNumber") List<List<BigDecimal>> arrayArrayNumber) {
       this.arrayArrayNumber = arrayArrayNumber;
</file context>
Suggested change
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public ArrayOfArrayOfNumberOnly(@JsonProperty("ArrayArrayNumber") List<List<BigDecimal>> arrayArrayNumber) {
this.arrayArrayNumber = arrayArrayNumber;
}
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public ArrayOfArrayOfNumberOnly(@JsonProperty("ArrayArrayNumber") List<List<BigDecimal>> arrayArrayNumber) {
this.arrayArrayNumber = arrayArrayNumber != null ? arrayArrayNumber : new ArrayList<>();
}
Fix with Cubic

* Constructor with only required parameters
*/
public TypeHolderExample(String stringItem, BigDecimal numberItem, Float floatItem, Integer integerItem, Boolean boolItem, List<Integer> arrayItem) {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: @JsonCreator constructor can override the default non-null list with null when array_item is missing, violating the @NotNull contract for arrayItem.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/TypeHolderExample.java, line 47:

<comment>@JsonCreator constructor can override the default non-null list with null when array_item is missing, violating the @NotNull contract for arrayItem.</comment>

<file context>
@@ -44,7 +44,8 @@ public TypeHolderExample() {
    * Constructor with only required parameters
    */
-  public TypeHolderExample(String stringItem, BigDecimal numberItem, Float floatItem, Integer integerItem, Boolean boolItem, List<Integer> arrayItem) {
+  @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
+  public TypeHolderExample(@JsonProperty("string_item") String stringItem, @JsonProperty("number_item") BigDecimal numberItem, @JsonProperty("float_item") Float floatItem, @JsonProperty("integer_item") Integer integerItem, @JsonProperty("bool_item") Boolean boolItem, @JsonProperty("array_item") List<Integer> arrayItem) {
     this.stringItem = stringItem;
</file context>
Fix with Cubic

*/
public Pet(String name, List<String> photoUrls) {
this.name = name;
this.photoUrls = photoUrls;
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Property-based @JsonCreator overwrites list defaults with null for missing JSON properties, making photoUrls/tags nullable and violating the non-null expectations.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/server/petstore/springboot-jspecify/src/main/java/org/openapitools/model/Pet.java, line 95:

<comment>Property-based @JsonCreator overwrites list defaults with null for missing JSON properties, making photoUrls/tags nullable and violating the non-null expectations.</comment>

<file context>
@@ -0,0 +1,300 @@
+   */
+  public Pet(String name, List<String> photoUrls) {
+    this.name = name;
+    this.photoUrls = photoUrls;
+  }
+
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant