OpenAPITools / OpenAPITools/openapi-generator

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

Open
#13,026 5 comments 1 reaction 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?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
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

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 linked openapi-test repository and its api.yaml; run the Makefile's make all in Docker and compare test1 with test2 and test3 at localhost:8080/v1. Done when the generated Java behavior for the $ref multipart/form-data case matches the working non-reference cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.