OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Generated object has no properties of intermediate parents
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
Version 4.3.1 generates inherited classes. So D extends C extends B extends A.
But there is no more inheritance as I understood.
So I expect that
- D has properties of C, B, A (first, second, third, fourth)
- C - B and A (first, second, third)
But they get properties of the root class A only
- D: first, fourth
- C: first, third
I'm able to fix it with to following markup
C:
allOf:
- $ref: '#/components/schemas/B'
- type: object
properties:
third:
type: string
but extra C[B]AllOf.java classes are generated.
openapi-generator version
5.1.1
OpenAPI declaration file content or url
openapi: 3.0.2
info:
title: Example
version: 0.0.1
servers:
- url: https://myserver
paths:
/go:
post:
tags:
- GO
operationId: go
requestBody:
content:
application/json:
schema:
type: object
properties:
shortObject:
$ref: '#/components/schemas/B'
longObject:
$ref: '#/components/schemas/D'
responses:
200:
description: OK
components:
schemas:
A:
type: object
properties:
first:
type: string
B:
allOf:
- $ref: '#/components/schemas/A'
type: object
properties:
second:
type: string
C:
allOf:
- $ref: '#/components/schemas/B'
type: object
properties:
third:
type: string
D:
allOf:
- $ref: '#/components/schemas/C'
type: object
properties:
fourth:
type: string
Generation Details
Gradle Plugin
generatorName = 'spring'
Steps to reproduce
Run the gradle task with the given yaml
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 running the Gradle spring generator with the OpenAPI YAML in the issue and inspect the generated D and C classes. Trace how the generator handles the A→B→C→D allOf chain; done means each generated class exposes all inherited properties without requiring extra C[B]AllOf.java classes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100