OpenAPITools / OpenAPITools/openapi-generator
[BUG][C++][QT5] OneOf, AnyOf and AllOf Handling Erroneous
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)?
- 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: https://github.com/OpenAPITools/openapi-generator/issues/15
Suggest a fix
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
Run the supplied OpenAPI declaration with the cpp-qt5-client generator command, then inspect the generated SchemaAllOf.h, SchemaOneOf.h, and SchemaAnyOf.h files. Compare the handling of all listed composition members and verify that the generated client includes every referenced schema and represents the compositions correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100