OpenAPITools / OpenAPITools/openapi-generator

[BUG] Different behaviour between openapi-generator-cli npm and docker distributions for the --generator-key arg

Open
#15,894 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

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)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I have got a typescript angular project that is using the @openapitools/openapi-generator-cli npm package to generate the openapi code locally on the dev machine. I have got an openapitools.json file that contains my generation config, which I then invoke with openapi-generator-cli generate --generator-key <my-key> in the scripts section of the package.json.

To do the same in the pipeline I was evaluating the openapitools/openapi-generator-cli docker image to avoid having to build a custom image that bundles node and java (and mvn,jq and curl when using the script).
However when running the same command that is working fine with the npm package, there is an [error] Found unexpected parameters: [--generator-key, <my-key>]. It seems like the docker version is requiring the -i arg and is not recognising the --generator-key.

openapi-generator version

6.6.0

OpenAPI declaration file content or url

Not important for this issue.

Generation Details

openapitools.json:

{
  "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "6.6.0",
    "generators": {
      "v3.0": {
        "generatorName": "typescript-angular",
        "inputSpec": "openapi/input/api.yaml",
        "output": "openapi/output",
        "additionalProperties": {
          "ngVersion": "12.1.0",
          "modelFileSuffix": ".model",
          "fileNaming": "camelCase",
          "enumPropertyNaming": "UPPERCASE"
        }
      }
    }
  }
}
Steps to reproduce
  1. Generate a new angular project
  2. Install the openapi-generator-cli via npm: npm install @openapitools/openapi-generator-cli -D
  3. Add a openapi/input/api.yaml file with some openapi definition to the project
  4. Add the openapitools.json as described above to the project
  5. Run npx openapi-generator-cli generate --generator-key v3.0 and observe the successful generation
  6. Run docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate --generator-key v3.0 as described in the docker instructions and observe the [error] Found unexpected parameters: [--generator-key, v3.0] error
Related issues/PRs
Suggest a fix

I would expect the same feature set from the npm and docker distributions since both share the same name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two commands from the issue with the documented npm package and Docker image at version 6.6.0, using the supplied openapitools.json and generator key. Compare how each distribution handles the generate --generator-key entry point; done means the Docker command accepts the same option and produces equivalent generation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, nodejs, openapi
Domain
cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.