Open jb-adams opened 3 years ago
The current README says to install this tool globally with npm install -g
. The reason I shy away from this is because I usually look for solution that does not require the user to modify his/her global development environment.
Using npx
solves this issues but has two drawbacks:
npx <command>
is slower as npx sends requests to the Internet each time it's executedgh-openapi-docs
cannot be used without access to Internet, which is the issue you are facing.Proposed solution:
Rely on local install npm install
+ running ./node_modules/.bin/<command>
$ ./node_modules/.bin/openapi
Usage: openapi [options] [command]
Options:
-v, --version Output current version of the OpenAPI CLI.
-h, --help output usage information
Commands:
bundle [options] [entryPoints...] Create a bundle using <entryPoint> as a root document.
validate [options] [entryPoints...] Validate given OpenAPI 3 definition file.
preview-docs [options] [entryPoint] Preview API Reference docs for the specified entrypoint OAS definition
We could send the paths to the command in the config object with the default path set to ./node_modules/.bin/<command>
. If the user want to use another version for some reason, he/she could overrides the paths in the config file.
I'm actually not sure how the above solution would work when gh-openapi-docs
is installed from npmjs. The easy solution is to continue using npm install -g
. Alternatively we could investigate on how to use openapi
and redocly
as libraries instead of running their executables.
Yeah, I'm good to leave this one as is. My above error was related to dependencies being incorrectly installed in the docker image, which I've since rectified.
As you mention, it'll be good once there's a library API for these packages that we can import rather than run on the command line, but last time I checked there was nothing available.
Feel free to close this issue
Can we remove the
npx
at the beginning of the following commands, especially since theREADME
states to install the two dependencies globally:npx openapi bundle -f --output ${OPENAPI_JSON_PATH} ${config.apiSpecPath}
npx openapi bundle -f --output ${OPENAPI_YAML_PATH} ${config.apiSpecPath}
npx redoc-cli bundle --output ${indexPath} ${OPENAPI_YAML_PATH} ${redocOpts}
I am making a docker image of this app, and currently some of the steps are failing when the command is run with
npx
at the beginning.command:
npx openapi bundle -f --output openapi.yaml service-registry.yaml
error:However when I just run:
openapi bundle -f --output openapi.yaml service-registry.yaml
the job completes successfully