OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript] Model for oneOf types not being generated.
Open
Nobody has claimed this yet.
Issue: Bug
- 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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
Description
The generated typescript client API does not include files for types with oneOf schemas. The API class includes the import, but the model is missing.


openapi-generator version
5.0.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
version: 1.0.0
title: "Typescript client oneOf Test"
tags:
- name: Test
description: "Test API"
paths:
"/test":
get:
tags:
- Test
operationId: test
responses:
"200":
description: "Test response"
content:
application/json:
schema:
$ref: "#/components/schemas/Test"
components:
schemas:
A:
type: object
properties:
hello:
type: string
B:
type: object
properties:
world:
type: string
Test:
type: array
items:
oneOf:
- $ref: "#/components/schemas/A"
- $ref: "#/components/schemas/B"
Generation Details & Steps to reproduce
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g typescript -i ./api.yml -o ./src --additional-properties=supportsES6=true,useObjectParameters=true
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
Start with the provided OpenAPI YAML and run the listed openapi-generator CLI command for the typescript generator. Compare the API import with the generated model files; the work is done when schemas using oneOf produce the expected model file and the generated client remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100