Skip to content

[BUG] JSON serialized query-parameters are generated wrong #2519

Description

@davidkarlsen

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

https://swagger.io/docs/specification/describing-parameters/#schema-vs-content states that query params with content application/json will be:
filter={"type":"t-shirt","color":"blue"}, but it generated like:

    public AccountListResponseType accountList(@QueryParam("customerId") @NotNull String customerId, @QueryParam("pagingInputElement")  UNKNOWN_PARAMETER_NAME);
```

##### openapi-generator version
3.3.4

##### OpenAPI declaration file content or url

```
 get:
      tags:
        - Account resource
      summary: list accounts
      operationId: accountList
      parameters:
        - name: customerId
          required: true
          in: query
          schema:
            type: string
        - name: pagingInputElement
          # required: true
          in: query
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PagingInputElementType'
```

##### Command line used for generation

```
 <configuration>
              <inputSpec>${project.basedir}/src/main/resources/META-INF/resources/api-v1.yaml</inputSpec>
              <validateSpec>true</validateSpec>
              <generatorName>jaxrs-cxf</generatorName>
              <generateSupportingFiles>false</generateSupportingFiles>
              <generateApiTests>false</generateApiTests>
              <generateModelDocumentation>false</generateModelDocumentation>
              <withXml>true</withXml>
              <!-- https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/jaxrs-cxf.md -->
              <configOptions>
                <!-- important to add this or else codegen is malfunctioning: -->
                <sourceFolder>src/gen/java/main</sourceFolder>
                <interfaceOnly>true</interfaceOnly>
                <useJackson>true</useJackson>
                <dateLibrary>java8</dateLibrary>
                <serializableModel>true</serializableModel>
                <java8>true</java8>
                <booleanGetterPrefix>is</booleanGetterPrefix>
                <useBeanValidation>true</useBeanValidation>
                <addConsumesProducesJson>true</addConsumesProducesJson>
              </configOptions>
```

##### Steps to reproduce

See above

##### Related issues/PRs

N/A

##### Suggest a fix

generate properly named parameter of proper type


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions