Closed
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?
- [Optional] Bounty to sponsor the fix (example)
Description
Starting from openapi-generator v4.3.1 and using the typescript-fetch, the following error occurs when compiling the generated typescript code:
> tsc
src/apis/DefaultApi.ts:18:5 - error TS2305: Module '"../models"' has no exported member 'AnyType'.
18 AnyType,
~~~~~~~
src/apis/DefaultApi.ts:19:5 - error TS2305: Module '"../models"' has no exported member 'AnyTypeFromJSON'.
19 AnyTypeFromJSON,
~~~~~~~~~~~~~~~
src/apis/DefaultApi.ts:20:5 - error TS2305: Module '"../models"' has no exported member 'AnyTypeToJSON'.
20 AnyTypeToJSON,
~~~~~~~~~~~~~
Found 3 errors.
openapi-generator version
Using openapi-generator v4.3.1 and typescript-fetch.
This is a regression as I was not able to reproduce it on v4.3.0
OpenAPI declaration file content or url
# openapi.yml
openapi: 3.0.2
info:
title: Example API
version: 1.0.0
paths:
/some-working-route/:
get:
operationId: listWorking
description: ''
parameters: []
responses:
'200':
content:
application/json:
schema:
type: object
properties:
id:
type: integer
name:
type: string
description: ''
/some-failing-route/:
get:
operationId: listFailing
description: ''
parameters: []
responses:
'200':
content:
application/json:
schema:
type: array
items: {}
description: ''
servers:
- url: http://localhost
Command line used for generation
# config.yml
typescriptThreePlus: true
npmName: some-example
npmVersion: '1.0.0'
docker run --rm \
-v ${PWD}:/local
--user "$(id -u):$(id -g)" \
openapitools/openapi-generator-cli:v4.3.1 generate \
-i /local/openapi.yml \
-g typescript-fetch \
-c /local/config.yml \
-o /local/dist
Steps to reproduce
- Download
openapi.yml
andconfig.yml
pasted above. - Run the docker command pasted above
cd dist
npm install
to install typescript and runtsc
(becausetsc
is called in the post-install script in thepackage.json
file)
Related issues/PRs
Seems to be linked to this PR : #6091
Suggest a fix
The previous version set the type of empty object as object
.
It may be linked to @mwilby proposal on the PR:
typeMapping.put("AnyType", "object");