[BUG] Multi Level Inheritance not generated correctly
Created by: rlsf
As can be seen in these issues: https://github.com/OpenAPITools/openapi-generator/issues/1685 https://github.com/OpenAPITools/openapi-generator/issues/2928
there is a problem with generating multi-level hierarchy with OpenAPI 4.x.x and 5.x.x. the problem exists in numerous languages that we tested so we guess that it is a problem with the main code.
For example for the yaml below taken from issue 1685 version 3.3.4 generates the expected
class Animal {…}
class Cat extends Animal {…}
class Dog extends Animal {…}
class BigDog extends Dog {…}
While 4.xx and 5.xx generate
class Animal {…}
class Cat extends Animal {…}
class Dog extends Animal {…}
class BigDog {…}
generation was executed using the maven-openapi-generator of the respective version (4.x.x and 5.x.x)
openapi: 3.0.0
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
paths:
/animals:
get:
summary: Returns all animals.
description: Optional extended description in Markdown.
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Animal'
components:
schemas:
Dog:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
breed:
type: string
Cat:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
breed:
type: string
BigDog:
allOf:
- $ref: '#/components/schemas/Dog'
- type: object
discriminator:
propertyName: dogType
required:
- dogType
properties:
dogType:
type: string
declawed:
type: boolean
Animal:
type: object
discriminator:
propertyName: className
required:
- className
properties:
className:
type: string
color:
type: string
default: red