Skip to content

[BUG][typescript-axios] missing discriminator #5262

@cervotoc

Description

@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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions