swagger-api / swagger-api/swagger-core
Incorrect OpenAPI specification produced for an Iterable of enums in Scala
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
Describe the bug
When I have a field of type Iterable of an enum, e.g. a Set or a Seq, then springdoc is not generating the correct OpenAPI specification.
To Reproduce
Steps to reproduce the behavior:
What version of spring-boot you are using?
Version 3.2.5.
What modules and versions of swagger-core are you using?
I'm using version 2.5.0 of the org.springdoc:springdoc-openapi-starter-webmvc-ui module, which in turn has a dependency on version 2.2.21 on io.swagger.core.v3:swagger-core-jakarta.
What is the actual and the expected result using OpenAPI Description (yml or json)?
Expected result:
"fareClasses": {
"type": "array",
"description": "FareClasses",
"items": {
"type": "string",
"enum": [
"FIRST_CLASS",
"SECOND_CLASS",
"THIRD_CLASS",
"ECONOMY_CLASS"
]
}
}
Actual result:
"fareClasses": {
"type": "array",
"description": "FareClasses",
"items": {
"type": "string"
}
}
Please refer to the sample code that reproduces the issue.
Expected behavior
The fareClasses field should be an enum.
I originally posted this issue in the springdoc issue tracker, but realised that this might be an issue in swagger-core.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the linked springdoc-scala-bug sample with Spring Boot 3.2.5, springdoc-openapi 2.5.0, and swagger-core 2.2.21, then compare the generated OpenAPI for the Iterable enum field with the expected JSON in this issue. Done means the array items preserve the enum values for Set and Seq cases, with regression coverage added where the project’s existing schema tests fit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, scala, spring-boot
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100