OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-angular] Tagged unions not working as expected
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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a typescript-angular client with taggedUnion an empty interface is generated where a union is expected
openapi-generator version
7.12.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: OpenAPI definition
version: v0
paths:
/api/test/zoo:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Zoo'
components:
schemas:
Animal:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
required:
- type
Cat:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
purrFrequency:
type: integer
format: int32
Dog:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
barkVolume:
type: integer
format: int32
Zoo:
type: array
items:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
Generation Details
openapi-generator-cli generate -i ./allOf_composition_discriminator_collection.yaml -g typescript-angular -o ./out --additional-properties=taggedUnion=true
Steps to reproduce
Created a failing test.
In essence - the expected output in /model/zooInner.ts should contain:
export type ZooInner = Cat | Dog;
But in reality contains:
export interface ZooInner {
}
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 linked TypeScriptAngularClientCodegenTest.java failing test and reproduce the generation command using the provided OpenAPI declaration. Inspect the generated /model/zooInner.ts output for the tagged union case. Done means it declares ZooInner as Cat | Dog rather than an empty interface, with the test passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100