OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-axios] missing discriminator
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
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
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 provided OpenAPI Generator command with the embedded specification and inspect src/api/generated/model/ae-item-vo.ts. Compare the generated AeItemVO interface with the expected output, then trace the typescript-axios generator code that produces it. Done means the discriminator property is included for this multiple-inheritance case without breaking the generated models.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100