Skip to content

Whether an array is required or not should be controlled by ArraySchema.arraySchema.requiredMode instead of ArraySchema.schema.requiredMode #4341

@keigo-brook

Description

@keigo-brook

After replaced the option required at @Schema annotation by requiredMode on #4286, it seems the issue #3438 is shown again.

According to the comments of ArraySchema annotation, ArraySchema.schema defines the model of the items within the array, while ArraySchema.arraySchema defines the model for the model of the array itself.

Example

In this example, I provide an almost same example at the #3438.

For the below DTO class:

public class Person {
    @ArraySchema(
        arraySchema = @Schema(requiredMode = RequiredMode.REQUIRED)
    )
    private List<String> addresses;
}

I expect the generated special to have (but it's not):

{
  "Person": {
    "required": [
      "addresses"
    ]
  }
}

And I need to work around this by:

public class Person {
    @ArraySchema(
        arraySchema = @Schema(description = "The person"),
        schema = @Schema(requiredMode = RequiredMode.REQUIRED)
    )
    private List<String> addresses;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions