OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.98k stars 6.6k forks source link

[BUG][typescript-node] Missing type argument when using oneOf, $ref & Array #10000

Open lupus92 opened 3 years ago

lupus92 commented 3 years ago
Description

When using oneOf with $ref and the content of $ref is an array, the generator ignores the type of the array which leads to the typescript error: Error:(20, 20) TS2314: Generic type 'Array<T>' requires 1 type argument(s).

export class Schema1MyData {
    'data'?: any | Array;    // this should be Array<string>!
//...
openapi-generator version

5.2.0

OpenAPI declaration file content
openapi: 3.0.1
info:
  title: Test
  version: 1.0.0

paths:
  /test:
    get:
      summary: tmp
      responses:
        '200':
          description: Test
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Schema1'

components:
  schemas:
    Schema1:
      type: object
      properties:
        myData:
          type: object
          properties:
            data:
              oneOf:
                - $ref: '#/components/schemas/Schema2'
                - $ref: '#/components/schemas/Schema3'

    Schema2:
      type: object
      additionalProperties:
        type: string

    Schema3:
      type: array
      items:
        type: string
Command line used for generation

--generator-name=typescript-node

wamujlb commented 2 years ago

Having the same issue. Didn't have it using the previous version.