OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA] MergedSpec is not created correctly on Windows with inputSpecRootDirectory and nested directories

Open Beginner friendly
#23,337 0 comments 0 reactions 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?
  • 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

When using the generator under windows with inputSpecRootDirectory and specs separated in folders the generated merged spec contains invalid refs. For example:
... $ref: "./details\\details-transactions-api.yaml...
instead of
... $ref: "./details/details-transactions-api.yaml...

The result is that the nested specs are not used for generation and the expected artifacts are missing (tested in spring and typescript-axios generator). Side effect are warnings like the following:
Model details\details-transactions-api not generated since it's a free-form object

openapi-generator version

tested on 7.17.0 an 7.20.0

Suggest a fix

MergedSpecBuilder uses File.separator for generating the refs. It would be probably sufficient zu use OS-independently/as separator instead.

https://github.com/OpenAPITools/openapi-generator/blob/c1e03615f3fe801000ef30d66cc594122d9ecfcd/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/MergedSpecBuilder.java#L67

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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/config/MergedSpecBuilder.java around line 67 and reproduce the issue on Windows with inputSpecRootDirectory and nested spec folders. Check the generated merged spec refs and verify that nested specs are used during generation without missing artifacts or free-form object warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.