Openapi-generator: [BUG] [typescript-fetch] v4.3.1 introduced "Module has no exported member 'AnyType"

Created on 12 May 2020  路  4Comments  路  Source: OpenAPITools/openapi-generator

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] What's the version of OpenAPI Generator used?
  • [x] Have you search for related issues/PRs?
  • [x] 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 and config.yml pasted above.
  • Run the docker command pasted above
  • cd dist
  • npm install to install typescript and run tsc (because tsc is called in the post-install script in the package.json file)
Related issues/PRs

Seems to be linked to this PR : https://github.com/OpenAPITools/openapi-generator/pull/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");
TypeScript Bug

Most helpful comment

Same thing happening with Kotlin generator.

All 4 comments

馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

Same problem with the python-flask generator

Same thing happening with Kotlin generator.

Was this page helpful?
0 / 5 - 0 ratings