OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA] Enum array are no longer validated

Open
#19,798 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

For enum array, the use of validation field doesn't add the validation to the java class.

For example, this

closing_days:
  type: array
  minItems: 1
  items:
    type: string
    enum: [ MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ]

Does not add a validation @Size(min = 1) annotation with useBeanValidation.

In fact, this looks like since https://github.com/OpenAPITools/openapi-generator/pull/18658, any validation is skipped for enums.

openapi-generator version

7.8.0

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/18658

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the OpenAPI schema example and related PR 18658 first, focusing on how useBeanValidation handles enum arrays. Confirm that the generated Java class includes @Size(min = 1) for minItems while retaining enum handling, then verify the behavior with the reported 7.8.0 case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
backend-api-design, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.