Skip to content

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

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

Open
4 of 6 tasks
davidkarlsen opened this issue Mar 26, 2019 · 3 comments
Open
4 of 6 tasks

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

davidkarlsen opened this issue Mar 26, 2019 · 3 comments

Comments

@davidkarlsen
Copy link

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


@davidkarlsen
Copy link
Author

Related to spec discussion OAI/OpenAPI-Specification#1706

@kaburke
Copy link

kaburke commented Jul 16, 2021

The referenced discussion doesn't seem to address the issue. This bug report is concerning parameters using the content property, allowing for the specification of the content type. This bug is pointing out that when the content is set to application/json, the generator ignores the specification. The generated client doesn't pass json data, as requested.

@hejianchao
Copy link

Is there any progress on this issue?

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

No branches or pull requests

3 participants