OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.48k stars 6.5k forks source link

[BUG][Java] `$ref` with `multipart/form-data` is always null #13026

Open jeffshee opened 2 years ago

jeffshee commented 2 years ago

Bug Report Checklist

Description

As titled, when a property is referenced using $ref with multipart/form-data in the requestBody, such property is always null. It works otherwise when not using $ref, or when not using multipart/form-data. This issue might only occur with the above combinations.

openapi-generator version

I tested with docker images of openapi-generator-cli v5.2.0 and v5.4.0. Both have the same issue. I couldn't test with the latest docker images v6.0.1. The server gives HTTP error 503 for all requests and refuses to work. This is also the reason why I couldn't test with the latest master. (This would be another issue.)

OpenAPI declaration file content or url

For the source codes to reproduce the issue, please refer to this repo: https://github.com/jeffshee/openapi-test The OpenAPI declaration file can be found here: https://github.com/jeffshee/openapi-test/blob/master/api.yaml

Generation Details
Steps to reproduce

Docker environment is required for using the Makefile provided in the repo.

  1. Clone the repo.
  2. Execute make all to compile and run the docker image.
  3. Test the APIs run at http://localhost:8080/v1. test1 is not working. For comparison, test2 and test3 are working.
Related issues/PRs

N/A

Suggest a fix

N/A

jeffshee commented 2 years ago

Hi, how is this issue going? Do you need any additional info?

RomioSahoo commented 2 years ago

Tried out using a workaround from https://github.com/OpenAPITools/openapi-generator/issues/10415#issuecomment-1003067496 and it fixes the issue.

jeffshee commented 2 years ago

@RomioSahoo Thanks. Did you tried the workaround with the test source code that I provided above? I tried adding the option --global-property skipFormModel=true to the generator and it didn't fix the issue.

labibdotc commented 5 months ago

@jeffshee it is true by default. Try setting to false instead.