Skip to content

Enum Collection parameter missing type info in Spring Data Rest search method #2001

Closed
@ParkerM

Description

@ParkerM

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 and springdoc-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

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:
image

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:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions