Git Product home page Git Product logo

Comments (13)

momesana avatar momesana commented on May 20, 2024 2

We have the same issue with pnpm. It happens when we invoke openapi-generator-cli (version 6.3.0) via pnpm (version 7.27.0) with the --dir flag from outside the project's root folder i.e.:

pnpm --dir <path to the projects root folder> run generate-sources

generate-sources in turn is defined as follows in the respective package.json's script section:

"generate-sources": "openapi-generator-cli generate"

The generation of types runs as part of the CI on windows, mac and linux. It only fails on windows. Furthermore it didn't cause any problems when used in conjunction with yarn and only appeared after switching to pnpm. The workaround for us is to change into the project directory and execute pnpm without --dir. It's worth noting that we have a bunch of different scripts all executed with --dir and they work flawlessly across all systems so this is likely an issue that pertains to openapi-generator-cli and not to pnpm.

from openapi-generator-cli.

kay-schecker avatar kay-schecker commented on May 20, 2024

I guess it's an issue with the current cwd. I'll fix it asap

from openapi-generator-cli.

kay-schecker avatar kay-schecker commented on May 20, 2024

which OS, Node and NPM you are using?

from openapi-generator-cli.

streetclaw avatar streetclaw commented on May 20, 2024
  • npm: 6.14.8
  • node: 14.12.0 / 14.13.0 (also present with the newest version)
  • os: macOS 10.15.7

edit: running npm with --verbose shows that CWD points to the project root where the openapitools.json is located in.

from openapi-generator-cli.

kay-schecker avatar kay-schecker commented on May 20, 2024

fixed with v2.0.3

from openapi-generator-cli.

streetclaw avatar streetclaw commented on May 20, 2024

The error still appears with version 2.0.3. At least for me. Minimal example (tested on macOS, arch linux and windows):
cli_example.zip

  1. run npm install to install openapi-generator-cli version 2.0.3
  2. run npm run generate:openapi

from openapi-generator-cli.

kay-schecker avatar kay-schecker commented on May 20, 2024

Thanks, I'll check

from openapi-generator-cli.

kay-schecker avatar kay-schecker commented on May 20, 2024

You missed the generators node:

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "5.0.0-beta2",
    "generators": {
      "project-ts": {
        "generatorName": "typescript-axios",
        "output": "#{cwd}/src/api/#{name}",
        "glob": ".apiSchema/swagger/*.json"
      }
    }
  }
}

from openapi-generator-cli.

kay-schecker avatar kay-schecker commented on May 20, 2024

I'll add a new feature to validate the given config ...

from openapi-generator-cli.

streetclaw avatar streetclaw commented on May 20, 2024

Yes, sorry I should have noticed.

from openapi-generator-cli.

RichardBradley avatar RichardBradley commented on May 20, 2024

I still get this error on the latest version.

Is there a workaround? I can't even figure out how to get this tool to print what Java command it is invoking so I can work around.

I'm on v 2.5.2 (latest at time of writing), Cygwin on Windows, Node 14. Here's all relevant info I can think of:

$ npx --version
6.14.17
$ npm --version
6.14.17
$ node --version
v14.20.0
$ npx openapi-generator-cli version
6.0.1
$ grep openapi-generator ../../package.json
    "@openapitools/openapi-generator-cli": "^2.5.2",
$ cat openapitools.json
{
  "$schema": "../../node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "6.0.0",
    "generators": {
      "my-spec-gen": {
        "generatorName": "typescript-rxjs",
        "output": "./generated",
        "inputSpec": "./reference/my-spec.yaml"
      }
    }
  }
}
$ npx openapi-generator-cli generate
Download 6.0.1 ...
Downloaded 6.0.1
[error] Required option '-i' is missing

Any ideas what I can do to diagnose or fix?

from openapi-generator-cli.

RichardBradley avatar RichardBradley commented on May 20, 2024

I was able to work around by invoking Java directly:

 java -jar ../../node_modules/@openapitools/openapi-generator-cli/versions/6.0.1.jar generate -i ./reference/my-api.yaml -o generated -g typescript-rxjs

.. still not sure what's up with openapi-generator-cli or how to diagnose further. I wasn't able to get any diagnostic logs, and the main.js seems minified so I couldn't investigate further.

from openapi-generator-cli.

tajnymag avatar tajnymag commented on May 20, 2024

Found the issue!

Openapi-generator-cli is using INIT_CWD as its working directory:

public readonly cwd = process.env.PWD || process.env.INIT_CWD || process.cwd()

When I ran my pnpm test script from a different directory (pnpm -r or pnpm run --dir) I got:

> node cwd-test.js

process.env.PWD undefined
process.env.INIT_CWD C:\Users\marek\GitHub\vsb-eink-services
process.cwd() C:\Users\marek\GitHub\vsb-eink-services\packages\facade-api-client

There's an issue in pnpm discussing where INIT_CWD is supposed to point.

from openapi-generator-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.