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
  • #12728
Closed
Open
Issue created Jun 28, 2022 by Administrator@rootContributor4 of 4 checklist items completed4/4 checklist items

[BUG] [typescript-axios] Generated project does not compile with the supportsES6 option

Created by: ditsuke

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
Description

Client generated by the typescript-axios compiler does not compile if used with the generator's supportsES6 options set to true.

openapi-generator version

6.0.1-SNAPSHOT

OpenAPI declaration file content or url

https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/petstore.yaml

Generation Details
  • Generator: typescript-axios
  • Configuration:
    npmName: petstore_tsax_gen
    supportsES6: true
  • Full command: generate -i petstore.yaml -g typescript-axios -o out/ts-axios -c config.yaml
Steps to reproduce
  • Run npm install in the generated typescript project. This will first install dependencies then try to build the project with tsc
  • Build step output:
      api.ts:17:78 - error ts2792: cannot find module 'axios'. did you mean to set the 'moduleresolution' option to 'node', or to add aliases to the 'paths' option?
      
      17 import globalaxios, { axiospromise, axiosinstance, axiosrequestconfig } from 'axios';
    																				  ~~~~~~~
      
      common.ts:18:46 - error ts2792: cannot find module 'axios'. did you mean to set the 'moduleresolution' option to 'node', or to add aliases to the 'paths' option?
      
      18 import { axiosinstance, axiosresponse } from 'axios';
    												  ~~~~~~~
      
      
      found 2 errors in 2 files.
      
      errors  files
    	   1  api.ts:17
    	   1  common.ts:18
Related issues/PRs
Suggest a fix

Set "moduleResolution": "Node" in the tsconfig compiler options. I'll be happy to open a PR.

Assignee
Assign to
Time tracking