[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
- Clone https://github.com/bard/openapi-generator-missing-type
- Run
yarn install && yarn test
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/5995 seems to solve a similar issue