Open

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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
The generated code when using OneOf, AnyOf or AllOf contain errors, i.e.:
- AllOf: When a schema A for example uses AllOf together with > 1 subschemes (B, C, ...), only the first defined scheme (B) within AllOf is used within the generated client code for the scheme A.
- AnyOf and OneOf: Some included files are not generated.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 0.0.1
title: Test
paths:
/endpointAllOf:
put:
operationId: allOf
description: "-"
requestBody:
description: Content All Of
content:
application/json:
schema:
$ref: '#/components/schemas/SchemaAllOf'
responses:
200:
description: Success
/endpointOneOf:
put:
operationId: oneOf
description: "-"
requestBody:
description: Content One Of
content:
application/json:
schema:
$ref: '#/components/schemas/SchemaOneOf'
responses:
200:
description: Success
/endpointAnyOf:
put:
operationId: anyOf
description: "-"
requestBody:
description: Content Any Of
content:
application/json:
schema:
$ref: '#/components/schemas/SchemaAnyOf'
responses:
200:
description: Success
components:
schemas:
SchemaAllOf:
type: object
description: 'All Of Example'
properties:
information:
type: string
description: 'Some information field'
additionalInfo:
allOf:
- $ref: '#/components/schemas/OptionA'
- $ref: '#/components/schemas/OptionB'
SchemaAnyOf:
type: object
description: 'Any Of Example'
properties:
information:
type: string
description: 'Some information field'
additionalInfo:
anyOf:
- $ref: '#/components/schemas/OptionA'
- $ref: '#/components/schemas/OptionB'
SchemaOneOf:
type: object
description: 'One Of Example'
properties:
information:
type: string
description: 'Some information field'
additionalInfo:
oneOf:
- $ref: '#/components/schemas/OptionA'
- $ref: '#/components/schemas/OptionB'
OptionA:
type: object
description: 'Option A'
properties:
data1:
type: string
description: 'Data'
OptionB:
type: object
description: 'Option B'
properties:
data2:
type: number
description: 'Data'
Command line used for generation
java -cp openapi-generator-cli-4.3.1.jar org.openapitools.codegen.OpenAPIGenerator generate -i ${SPEC_FILE} -g cpp-qt5-client -o gen/ --model-name-prefix Test
Steps to reproduce
Execute code generation and take a look at the files (SchemaOneOf.h, SchemaAllOf.h, SchemaAnyOf.h, etc.).
Related issues/PRs
E.g. for oneOf: #15