OpenAPITools / OpenAPITools/openapi-generator
[BUG] Missing model files when using embedded/splitted spec files
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If I split YML file into 2 files, unused models (not used as a request or response body) are not generated. If everything is in a single file it works just fine.
So for an example below, model files created: Parent.java.
Model files NOT created: ChildOne.java and ChildTwo.java.
If we add e.g. ChildTwo entity into a post response, then it is generated, but ChildOne.java isn't.
openapi-generator version
4.2.2
OpenAPI declaration file content or url
Test project which reveals this issue:
https://github.com/zolv/openapi-generation-bug-report-1
Spec files (splitted):
openapi: 3.0.2
info:
title: API Documentation
version: 1.0.0
servers:
- url: http://localhost:8080/
paths:
/users:
$ref: './api-split-sub.yml#/test'
test:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Parent'
responses:
200:
description: It's OK
components:
schemas:
Parent:
required:
- status
properties:
status:
type: string
discriminator:
propertyName: status
mapping:
CHILD_ONE: '#/components/schemas/ChildOne'
CHILD_TWO: '#/components/schemas/ChildTwo'
ChildOne:
properties:
status:
type: string
discriminator:
- $ref: '#/components/schemas/Parent'
- type: object
ChildTwo:
allOf:
- $ref: '#/components/schemas/Parent'
- type: object
Command line used for generation
./gradlew clean openApiGenerate -s
Steps to reproduce
Nothing. It's just a command line execution.
Related issues/PRs
Nothing I could find.
My issue was first asked on SO
Suggest a fix
No suggestion for fix.
WOrkaround: put everything into single file.
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 linked test project and its docs/openapi/api-split.yml and api-split-sub.yml files, then run ./gradlew clean openApiGenerate -s to reproduce the generation. Compare the split-spec output with the single-file workaround; the work is done when ChildOne.java and ChildTwo.java are generated from the split specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100