OpenAPITools / OpenAPITools/openapi-generator

[BUG] Java: Not able to pass dictionary in query parameters

Open
#19,019 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • [ x] Have you validated the input using an OpenAPI validator (example)?
  • [ x] Have you tested with the latest master to confirm the issue still exists?
  • [x ] Have you searched for related issues/PRs?
  • [x ] What's the actual output vs expected output?
  • [ x] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I want to be able to pass a dictionary in the query params of an endpoint. To do this, I created following spec as example:

- name: metadata
          in: query
          required: false
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties:
              type: string      

There are 3 issues (bugs) I am facing:

when I run the openapi-codegenerator (I am running it via Maven plugin) ISSUE 1: it produces the same output irrespective of whether

          style: deepObject
          explode: true

is present or not in the yaml file. The generated Java code is this:

@Parameter(name = "metadata", description = "", in = ParameterIn.QUERY)
          @Valid
          @RequestParam(value = "", required = false)
          Map<String, String> metadata

Further in swagger-ui ISSUE 2: I do not see any UI element corresponding to the metadata variable in above.

I am using openapi: 3.0.1

ISSUE 3: my Spring boot endpoint is like this:

public ResponseEntity<Void> foo(
      String s1, String s2, Map<String, String> map, SomeEnum someEnum) {

Expected: map should not contain s1, s2, someEnum

Observed: map contains s1, s2, someEnum

openapi-generator version

7.4.0

Generation Details
Steps to reproduce
Related issues/PRs

I am not sure if this is same issue as this. Reading that issue it seemed like it is w.r.t. client code whereas my issue is w.r.t. server code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI 3.0.1 example using a query parameter with style deepObject and additionalProperties, then inspect the Java server output generated through the Maven plugin. Compare the generated parameter handling and Swagger UI behavior with and without style/explode, and verify that the Spring Boot map excludes the other endpoint parameters when the three reported issues are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.