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

[REQ][JAVA][Spring] Add support for SpringQueryMap in Feign clients #11624

Open
mhinders opened this issue Feb 16, 2022 · 0 comments · May be fixed by BitcoinOutput/openapi-generator#301
Open

Comments

@mhinders
Copy link

Is your feature request related to a problem? Please describe.

When defining a GET APIs we might want to use many different optional query parameters to filter e.g a collection resource like /books. With the current generator one would need to define all the properties as separate query parameters on the operation, resulting in an interface method with a lot of method arguments.

The preferable way would be to have an object that contains all query parameters. This would make the interfaces more stable as method signature would not change if an optional query parameter is added. Also it makes passing the parameters around on both client and backend side a lot nicer.

Describe the solution you'd like

I would like the generator to support defining one single query parameter which is an object contains all the query parameters like below.

paths:
  /books:
    get:
      summary: Search books
      operationId: search-books
      tags:
        - books
      parameters:
        - name: filter
          in: query
          required: true
          description: Search filter
          schema:
            $ref: '#/components/schemas/SearchFilter'
components:
  schemas:
    SearchFilter:
          type: object
          properties:
            publisherId:
              uniqueItems: true
              type: array
              items:
                type: integer
                format: int64
            name:
              type: string
            yearPublished:
              type: integer
              format: int32
            authorId:
              type: integer
              format: int64

Describe alternatives you've considered

Using a POST where payload contains the properties to filter by, but a benefit with GET is that one can see the parameters in access logs.

Additional context

Adding {{#isModel}} @org.springframework.cloud.openfeign.SpringQueryMap{{/isModel}} to queryParams.mustache seems to do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant