Fix kotlin-spring required property validation

KO
8d ago
+2185-10

Required kotlin-spring properties now generate as nullable fields with @field:NotNull so Bean Validation can surface missing values instead of Jackson failing at constructor time. Includes regression coverage for the required-nullable 4-state test case.


Summary by cubic

Fixes kotlin-spring required property handling to avoid early Jackson failures while keeping the default model contract. By default, required fields stay non‑nullable and do not get @field:NotNull; enabling nullableRequiredForBeanValidation makes them nullable and adds @field:NotNull so Bean Validation catches missing values.

  • Bug Fixes

    • With useBeanValidation, required properties keep @JsonProperty(required = true) and remain non‑nullable without @NotNull by default.
    • Added nullableRequiredForBeanValidation (default false) to emit ? and @field:NotNull for required fields; updated docs and tests for the four required/nullable scenarios, including the opt‑in path.
  • New Features

    • Added a Spring Boot 3 Petstore compilation sample and config (kotlin-springboot-3-nullable-required) to exercise nullableRequiredForBeanValidation with useBeanValidation=true, verifying nullable types plus @field:NotNull compile correctly.