swagger-api/swagger-codegen-generators

npmName and npmVersion options missing on typescript-axios generator

jdconley opened this issue · 1 comments

Based on the current master branch (and release 3.0.40).

I created this config file myapi-typescript.config:

{
  "npmName": "MyAPI",
  "npmVersion": "1.0.0"
}

And tried to use it:

swagger-codegen generate -i swagger.json -l typescript-axios -o myapi-typescript -c myapi-typescript.config

But the resulting package.json has no name set:

{
  "name": "",
  "version": "",
  "description": "OpenAPI client for ",
  "author": "OpenAPI-Generator Contributors",
  "keywords": [
    "axios",
    "typescript",
    "openapi-client",
    "openapi-generator",
    ""
  ],
  "license": "Unlicense",
  "main": "./dist/index.js",
  "typings": "./dist/index.d.ts",
  "scripts": {
    "build": "tsc --outDir dist/",
    "prepublishOnly": "npm run build"
  },
  "dependencies": {
    "axios": "^0.21.1"
  },
  "devDependencies": {
    "@types/node": "^12.11.5",
    "typescript": "^3.6.4"
  }
}

I attempted to configure the package name and version from a config file the same way I would for the typescript-angular language option and noticed the package name and version is always empty. I dug into the code and it looks like the typescript-axios generator does not include the npmName and npmVersion as options (or support any additional options) but the options are used in the mustache files. And indeed they do not show up in swagger-codegen config-help -l typescript-axios

You can see the unused NPM_NAME here:

In contrast the angular generator uses the NPM_NAME in createOptions:

Maybe these common options should be in the AbstractTypeScriptClientCodegen.java ?

solved by #960