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
  • #5262
Closed
Open
Issue created Feb 10, 2020 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[BUG][typescript-axios] missing discriminator

Created by: cervotoc

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

While using multiple inheritance the generated classes do not include the discriminator field. This mean the server is unable to select correct implementation for the abstract class.

openapi-generator version

4.2.1-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: TEST
  version: "1.0"
paths:
  /test:
    post:
      operationId: test
      responses:
        200:
          description: result
          content:
            'application/json':
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AeItemVO'
components:
  schemas:
    AeItemVO:
      required:
        - itemTypeId
        - textValue
      type: object
      properties:
        id:
          type: integer
          format: int32
        uuid:
          type: string
        itemTypeId:
          type: integer
          format: int32
        itemSpecId:
          type: integer
          format: int32
        textValue:
          type: string
      discriminator:
        propertyName: '@class'
        mapping:
          AeItemInteger: '#/components/schemas/AeItemIntegerVO'
          AeItemString: '#/components/schemas/AeItemStringVO'
    AeItemIntegerVO:
      allOf:
        - $ref: '#/components/schemas/AeItemVO'
        - type: object
          properties:
            value:
              type: integer
              format: int32
          required:
            - value
    AeItemStringVO:
      allOf:
        - $ref: '#/components/schemas/AeItemVO'
        - type: object
          properties:
            value:
              type: string
          required:
            - value
Command line used for generation

openapi-generator generate -i openapi.yml -g typescript-axios -o src/api/generated/ -p withSeparateModelsAndApi=true,apiPackage=api,modelPackage=model

Steps to reproduce

run the above command. The generated src/api/generated/model/ae-item-vo.ts contains

export interface AeItemVO {
    id?: number;
    uuid?: string;
    itemTypeId: number;
    itemSpecId?: number;
    textValue: string;
}

expected output is

export interface AeItemVO {
    '@class': string; // discriminator
    id?: number;
    uuid?: string;
    itemTypeId: number;
    itemSpecId?: number;
    textValue: string;
}
Related issues/PRs
Suggest a fix

add missing functionality

Assignee
Assign to
Time tracking