OpenAPITools / OpenAPITools/openapi-generator
oneOf not generating union class properties Typescript-Angular
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I am using the example provided in the tests for oneOf. Once I try to generate for typescript-angular I get the three classes:
// apple.ts
export interface Apple {
kind?: string;
}
// banana.ts
export interface Banana {
count?: number;
}
// fruit.ts
import { Apple } from './apple';
import { Banana } from './banana';
export type Fruit = Apple | Banana;
As you can see the color property of fruit is missing.
openapi-generator version
I was using version 4.0.1 with the docker version.
Docker image used was:
openapitools/openapi-generator-cli@sha256:d67438016ccf3067655eb12ce23aab2b6f3e89f916cd153ae9874251af82b3e2
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: fruity
version: 0.0.1
paths:
/:
get:
responses:
'200':
description: desc
content:
application/json:
schema:
$ref: '#/components/schemas/fruit'
components:
schemas:
fruit:
title: fruit
properties:
color:
type: string
oneOf:
- $ref: '#/components/schemas/apple'
- $ref: '#/components/schemas/banana'
apple:
title: apple
type: object
properties:
kind:
type: string
banana:
title: banana
type: object
properties:
count:
type: number
Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli@sha256:d67438016ccf3067655eb12ce23aab2b6f3e89f916cd153ae9874251af82b3e2 generate \
-i /local/input.yaml \
-g typescript-angular \
-c /local/config.json \
-o /local
Content of config.json is:
{
"apiPackage": "api",
"ngVersion": "6"
}
Steps to reproduce
Execute the test file using the provided command.
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
Reproduce the issue with input.yaml, config.json, and the typescript-angular generator using the command provided. Compare the generated fruit.ts with the schema and example in the issue; done means the color property is represented in the generated union type or its related output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, openapi, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100