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

[Java] Wrong form parameters #10371

Open
UnHumbleBen opened this issue Jul 7, 2020 · 0 comments
Open

[Java] Wrong form parameters #10371

UnHumbleBen opened this issue Jul 7, 2020 · 0 comments

Comments

@UnHumbleBen
Copy link
Contributor

UnHumbleBen commented Jul 7, 2020

Description

Something seems to have broken since version 3.0.20 with regards to form parameters because they are no longer generated as arguments to the api methods. Here is an example using petstore.yaml, comparing the java client SDK form method updatePetWithForm generated with version 3.0.20 to a java client SDK form method updatePetWithForm generated with the latest commit

     /**
      * Build call for updatePetWithForm
      * @param petId ID of pet that needs to be updated (required)
-     * @param name  (optional)
-     * @param status  (optional)
      * @param progressListener Progress listener
      * @param progressRequestListener Progress request listener
      * @return Call to execute
      * @throws ApiException If fail to serialize the request body object
      */
-    public com.squareup.okhttp.Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
+    public com.squareup.okhttp.Call updatePetWithFormCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {

As you can see, the form variables name and status have been ignored.

The corresponding method in petstore.yaml file looks like this:

operationId: updatePetWithForm
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
schema:
type: integer
format: int64
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string

Swagger-codegen version

I am using the latest version of swagger-codegen as of today

For the comparison diff above, I compared it to the homebrew swagger-codegen command line tool, which is version 3.0.20.

Steps to reproduce

It is quick and easy to reproduce by comparing to version 3.0.19 instead of comparing to version 3.0.20 (will have the same result)

After clone and building the 3.0.0 branch repo,

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i modules/swagger-codegen/src/test/resources/3_0_0/petstore.yaml -o samples/client/petstore/java/okhttp-gson  -l java
git diff samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java

This works because the latest version of PetApi.java in the repository is from version 3.0.19

Related issues/PRs

This PR #671 seems to fix this issue for typescript angular. A similar fix may be needed for java (and all it's respective libraries).

Edit: Upon further investigations, I believe the error actually lies somewhere in the transition from v1.0.20 to v1.0.21 in swagger-codegen-generators. I checked out the 3.0.20 version of this repo, and modified the pom.xml file here:

<swagger-codegen-generators-version>1.0.20</swagger-codegen-generators-version>

Changing from version 1.0.20 to 1.0.21-SNAPSHOT and this results in the form parameters error described above.

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

No branches or pull requests

1 participant