OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Subclass model was classified as a free-form object even though the super class has a property in it.
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
Response:
type: object
description: The response.
oneOf:
- $ref: '#/components/schemas/SuccessResponse'
- $ref: '#/components/schemas/ErrorResponse'
discriminator:
propertyName: type
mapping:
SUCCESS: '#/components/schemas/SuccessResponse'
ERROR: '#/components/schemas/ErrorResponse'
SuccessResponse:
type: object
description: The success response.
ErrorResponse:
type: object
description: The error response.
properties:
errorCode:
type: string
required:
- errorCode
I'm getting Model SuccessResponse not generated since it's a free-form object even if SuccessResponse technically has a type property inherited from Response and is definitely not a free-form object.
openapi-generator version
4.0.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/2044 fixed the case where the object/schema has a oneOf/allOf/anyOf but it didn't fix the case where the object is part of a oneOf.
Suggest a fix
A subclass should still be generated even if it's empty as long as the superclass is not empty.
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 reproducing Java generation with the provided oneOf schema and its inherited property, then read the approach from PR 2044. Trace the free-form-object classification for the subclass and compare it with the superclass handling. Done means the subclass is generated when its superclass has properties, with regression coverage for this schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100