OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][SPRING] referencing multiple external files in one OpenAPI file results in broken builds or code
Nobody has claimed this yet.
- 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
Currently, I'm working on migrating our old swagger 2.0 APIs to OpenAPI 3.0.1.
The migration process itself runs pretty smoothly.
Unfortunately, I've encountered many issues with OpenAPI 3.0.1 files referencing external YAML files (using relative paths) and it's relatively difficult to describe all of them within this ticket.
Therefore I created a GitHub repository for all the problems I've encountered (so far)
https://github.com/mlemnian/openapi-generator-issues
openapi-generator version
Tested with 6.4.0, 6.5.0 and 6.6.0-SNAPSHOT at 3d7c173eb2f40ff97d067eaa14d2991f2cd6b7a5
OpenAPI declaration file content or URL
I've created a dedicated GitHub repository for all the problems I've encountered (so far)
https://github.com/mlemnian/openapi-generator-issues
Generation Details
In my examples, I'm using always the following configs:
- maven 3.9.0
- java 17
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatorName>spring</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
<generateAliasAsModel>false</generateAliasAsModel>
<inputSpec>${project.basedir}/open-api.yaml</inputSpec>
<modelPackage>api.model</modelPackage>
<modelNameSuffix>DTO</modelNameSuffix>
<apiPackage>api</apiPackage>
<skipValidateSpec>false</skipValidateSpec>
<configOptions>
<useSpringBoot3>true</useSpringBoot3>
<performBeanValidation>true</performBeanValidation>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
</configuration>
</execution>
</executions>
Steps to reproduce
follow the description in the repo examples
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/11151
https://github.com/OpenAPITools/openapi-generator/issues/3848
https://github.com/OpenAPITools/openapi-generator/issues/1976
https://github.com/OpenAPITools/openapi-generator/issues/8844
Suggest a fix
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 with the examples in the linked openapi-generator-issues repository and the referenced open-api.yaml, then run the Maven generation configuration using the spring generator. Compare the generated output and build results when multiple external YAML files are referenced; done means the documented examples generate and build successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100