jskov / openapi-jaxrs-client

An OpenAPI JAX-RS client code generator
Apache License 2.0
1 stars 4 forks source link

Fields that are nullable but are also required generate bad code #606

Closed jskov-jyskebank-dk closed 5 months ago

jskov-jyskebank-dk commented 5 months ago

This schema contains adresseId which is both required and nullable:

    AdresseIdentifikationDto:
      title: Adresseindentifikation
      required:
        - adgangsadresseId
        - adresseId
      type: object
      properties:
        adresseId:
          type: string
          format: uuid
          nullable: true
        adgangsadresseId:
          type: string
          format: uuid
      additionalProperties: false

The code generated is:

  @JsonProperty(JSON_PROPERTY_ADRESSE_ID)
  @Schema(required = false, nullable = true)
  private UUID adresseId;
...

  @NotNull
  public UUID getAdresseId() {
    return adresseId;
  }

Deserialization fails when the field is present and null.

Should not be marked @NotNull, should have correct required=true+nullable=true in the @Schema

(Per)