A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/OpenAPITools/openapi-generator/issues/4130 below:

[BUG][typescript-angular] oneOf and anyOf generates incorrect model for primitive types · Issue #4130 · OpenAPITools/openapi-generator · GitHub

Description

Using oneOf or anyOf will generate a model with incorrect imports and wrong types.

import { boolean } from "./boolean";
import { Number } from "./number";
import { string } from "./string";
import { array } from "./array";
import { integer } from "./integer";
import { object } from "./object";

export interface Foo {
  id?: string;
  xxx?: Number | string | boolean | array | object | integer;
  yyy?: Number | string | boolean | array | object | integer;
}

The expected model is:

// no imports

export interface Foo {
  id?: string;
  xxx?: number | string | boolean | string[] | object;
  yyy?: number | string | boolean | string[] | object;
}
openapi-generator version

openapi-generator v4.1.3

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Foo
  version: '0001'
  description: The description
paths:
  /FooSet:
    get:
      summary: Get entities from FooSet
      responses:
        '200':
          description: Retrieved entities
          content:
            application/json:
              schema:
                type: object
                properties:
                  value:
                    type: array
                    items:
                      $ref: '#/components/schemas/NAMESPACE.Foo'
components:
  schemas:
    NAMESPACE.Foo:
      type: object
      properties:
        id:
          type: string
        xxx:
          anyOf:
            - type: string
            - type: number
            - type: boolean
            - type: array
              items:
                type: string
            - type: object
            - type: integer
        yyy:
          oneOf:
            - type: string
            - type: number
            - type: boolean
            - type: array
              items:
                type: string
            - type: object
            - type: integer
      title: Foo
Command line used for generation

npx openapi-generator generate -g typescript-angular -i openapi.yaml-o out/test

Steps to reproduce

Generate a typescript client using the above yaml.

Related issues/PRs

There appears to be a lot of issues related to oneOf and anyOf. But couldn't find any specifically about this.

SAnDAnGE, gbertoncelli and okmttdhr


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4