Description
Describe the bug
When a Collection<? extends Enum<?>>
is used as a parameter in a repository method, the generated schema is a generic array of objects instead of a array of enum strings.
An example of how it would be used is for an IN
query, like this example repository (full repro at ParkerM@42d3dbd):
@RepositoryRestResource
public interface EnumFieldHolderRepository extends Repository<EnumFieldHolder, Long> {
Streamable<EnumFieldHolder> findAllByEnumFieldIn(@Param("enumFields") List<EnumField> enumFields);
}
The generated path parameters schema does not contain type info for the enum schema.
To Reproduce
Steps to reproduce the behavior:
-
What version of spring-boot you are using?
Tested with 2.7.6 and the current version in master (2.7.5) -
What modules and versions of springdoc-openapi are you using?
springdoc-openapi-data-rest
andspringdoc-openapi-ui
1.6.13 (as well as current master) -
What is the actual and the expected result using OpenAPI Description (yml or json)?
The actual result for a scalar Enum parameter is correct, but the type info is missing for array values.
# Expected
parameters:
- name: enumFields
in: query
schema:
type: array
items:
type: string
enum:
- FOO
- BAR
# Actual
parameters:
- name: enumFields
in: query
schema:
type: array
items:
type: object
- Provide with a sample code (HelloController) or Test that reproduces the problem
Failing test case here that uses@RepositoryRestResource
: Add failing test case for enum collection parameter issue #2001 #2002
Expected behavior
Schema for parameters such as @Param("myEnums") List<MyEnum>
in RepositoryRestResource methods should be recognized as an array of enum strings by default.
Screenshots
The expected dropdown in swagger-ui:
What it looks like without the enum type info. Note that manually inputting string objects ends up adding quotes to the query, so sadly it cannot be used as a workaround: