Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6192
Closed
Open
Issue created May 06, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [typescript-fetch] Type for map>array>item generated but not imported

Created by: bard

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? 4.3.1
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When an item of an array of a map is specified through a referenced schema, the type for the item is not generated.

For example, for an endpoint specification of:

  "/characters":
    get:
      responses:
        "200":
          content:
            application/json:
              schema:
                additionalProperties:
                  type: array
                  items:
                    $ref: "#/components/schemas/Character"

And a schema specification of:

    Character:
      required: ["first", "name"]
      properties:
        id:
          type: integer
        name:
          type: string

The Character type is not generated:

api/apis/DefaultApi.ts:25:82 - error TS2304: Cannot find name 'Character'.

25     async charactersGetRaw(): Promise<runtime.ApiResponse<{ [key: string]: Array<Character>; }>> {
                                                                                    ~~~~~~~~~

api/apis/DefaultApi.ts:42:59 - error TS2304: Cannot find name 'Character'.

42     async charactersGet(): Promise<{ [key: string]: Array<Character>; }> {
                                                             ~~~~~~~~~


Found 2 errors.
openapi-generator version

4.3.1

OpenAPI declaration file content or url

https://github.com/bard/openapi-generator-missing-type/blob/master/example.yaml

Excerpt:

  "/characters":
    get:
      responses:
        "200":
          content:
            application/json:
              schema:
                additionalProperties:
                  type: array
                  items:
                    $ref: "#/components/schemas/Character"
Command line used for generation
openapi-generator generate -g typescript-fetch --additional-properties=typescriptThreePlus=true -i example.yaml -o api
Steps to reproduce
  1. Clone https://github.com/bard/openapi-generator-missing-type
  2. Run yarn install && yarn test
Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/5995 seems to solve a similar issue

Assignee
Assign to
Time tracking