swagger-api / swagger-api/swagger-parser
$ref imports generates new types for every yaml file
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
I've generated API via spring generator for java code by maven plugin and typescript-angular for frontend. I have many of YAML files(to keep the API separated and YAML files short). I am using imports of a model like:
$ref: 'anotheryamlfile.yaml#/components/schemas/Problem'
I tried also
$ref: './anotheryamlfile.yaml#/components/schemas/Problem'
Unfortunately, the ProblemVO class is generated separately for every YAML file(so different types are generated and they cannot be used as one type):

Setting withSeparateModelsAndApi to false doesn't help.
For the maven plugin, I have an execution goal per YAML file. Same for openapi-generator generate by the console.
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
Reproduce the issue with the separate YAML files, the Maven plugin executions, and the openapi-generator generate command described in the report. Trace how the $ref to anotheryamlfile.yaml#/components/schemas/Problem is resolved and how models are generated; done means the shared Problem schema produces one reusable type rather than a separate ProblemVO for each YAML file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, java, openapi, typescript
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100