Skip to content

[BUG] [javascript-flowtyped] Array alias is not generated properly in oneOf #6015

Open
@thSoft

Description

@thSoft

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

If an alternative of oneOf is an array type, the generated Array type will miss a required type argument.

openapi-generator version

4.3.0

OpenAPI declaration file content or url
openapi: '3.0.0'
info:
  version: 0.0.0
  title: Bug
paths:
  /bug:
    get:
      responses:
        default:
          $ref: '#/components/responses/Response'
components:
  responses:
    Response:
      description: response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Record'
  schemas:
    Record:
      properties:
        property:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/Element'
              - $ref: '#/components/schemas/List'
    Element:
      properties:
        foo:
          type: integer
          format: int64
          example: 1
    List:
      type: array
      items:
        type: string
Command line used for generation

openapi-generator generate -i bug.yaml -g javascript-flowtyped -o bug/

Steps to reproduce
  • Generate code with the above command line
  • Check the generated code with flow check bug
  • You get
Cannot use type without exactly 1 type argument.

     93│      * @type {Array<Element | Array>}
     94│      * @memberof Record
     95│      */
     96│     property?: Array<Element | Array>;
     97│ }
     98│
     99│

because Array requires a type argument.

Related issues/PRs

I found none.

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