OpenAPITools / OpenAPITools/openapi-generator

[BUG][TYPESCRIPT] Bug generating type declaration for value type List<SomeType> within a Map.

Open
#6,749 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Error resolving $ref pointer "https://apitools.dev/swagger-parser/online/#/definitions/List".
Token "List" does not exist.

Unable to generate typescript client due to the following Error:
model/NotificationEvents.ts:16:40 - error TS2694: Namespace '../dist/otr-ts-client/model/models"' has no exported member 'List'.

The result type is.

export interface NotificationEvents {
    "events"?: { [key: string]: models.List; };
    "totalUnreadCount"?: number;
}
openapi-generator version

openapi-generator-cli 4.3.1
commit : 003165c
built : 2020-05-06T09:38:39Z

OpenAPI declaration file content or url
NotificationEvents":{"properties":{"events":{"type":"object","additionalProperties":{"$ref":"#/definitions/List"}},"totalUnreadCount":{"type":"integer","format":"int64"}}}
Command line used for generation

openapi-generator generate -i api/otr-service.json -g typescript-angularjs -o dist/otr-ts-client"

Steps to reproduce

After adding @types/angular as a dependency, I just ran the command below

tsc index.ts

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/2336

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied openapi-generator command with api/otr-service.json and inspect the generated model/NotificationEvents.ts output. Trace how the additionalProperties $ref for List is resolved in the typescript-angularjs generator. Done means the generated declaration no longer references a nonexistent models.List and the generated TypeScript passes tsc.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.