Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ParkerM opened this issue Dec 13, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@ParkerM
Copy link

ParkerM commented Dec 13, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants