Skip to content

oneOf not generating union class properties Typescript-Angular #3092

@ealtuna

Description

@ealtuna
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.

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