Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6378
Closed
Open
Issue created May 20, 2020 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][C++][QT5] OneOf, AnyOf and AllOf Handling Erroneous

Created by: ghost

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.:

  1. 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.
  2. 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
Assignee
Assign to
Time tracking