OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java] Java generator does not generate a model class for a schema named 'File'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
When an api.yml file contains a type definition called 'File' no model class is generated by the Java/spring generator for that type.
openapi-generator version
4.2.2
Details
The api.yaml file defines a type called File and an endpoint that returns a wrapper object containing a field of this type.
The generator is configured to use the package com.example.rest.model for generated model classes.
Expected behaviour:
- A class with the fully-qualified class name
com.example.rest.model.File
should be generated - The generated wrapper class
com.example.rest.model.FileWrappershould contain
a field calledfileof typecom.example.rest.model.File
Actual behaviour:
- No model class called
com.example.rest.model.Fileis generated - The
filesfield of the generated wrapper class is of typejava.io.File
Partial workaround:
The second issue (incorrect import type) can be worked around by explicitly adding the import-mapping File=com.example.rest.model.File to the configuration.
However, the class com.example.rest.model.File is still not generated.
Steps to reproduce
To reproduce, extract the attached oas-generator-file-bug.tar.gz file cd into the extracted project dir and run mvn clean generate-sources
Alternatively, the api.yaml file and a pom.xml configured to use the generator maven plugin can be seen here: https://gist.github.com/daiscog/71908355396370a6a4316d0adfeb6d31
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by extracting the attached project and running mvn clean generate-sources with its api.yaml and pom.xml. Then trace how the Java/Spring generator handles a schema named File, import mappings, and the FileWrapper field. Done means generating com.example.rest.model.File and making the wrapper field use that model rather than java.io.File.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100