Gathering detailed insights and metrics for @openapitools/openapi-generator-cli
Gathering detailed insights and metrics for @openapitools/openapi-generator-cli
Gathering detailed insights and metrics for @openapitools/openapi-generator-cli
Gathering detailed insights and metrics for @openapitools/openapi-generator-cli
A node package wrapper for https://github.com/OpenAPITools/openapi-generator
npm install @openapitools/openapi-generator-cli
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
1,466 Stars
1,024 Commits
154 Forks
19 Watching
21 Branches
43 Contributors
Updated on 27 Nov 2024
TypeScript (94.87%)
JavaScript (4.61%)
Nix (0.5%)
Shell (0.02%)
Cumulative downloads
Total Downloads
Last day
-3.9%
125,562
Compared to previous day
Last week
-0.2%
704,908
Compared to previous week
Last month
7.1%
3,064,289
Compared to previous month
Last year
45.5%
29,032,400
Compared to previous year
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (both 2.0 and 3.0 are supported). Please see OpenAPITools/openapi-generator.
The OpenAPI Generator is a Java project. openapi-generator-cli
will download the appropriate JAR file and invoke the java
executable to run the OpenAPI Generator. You must have the java
binary executable available on your PATH
for this to work. (JDK 11 is the minimal version supported. To install OpenJDK, please visit https://adoptium.net/)
If you find this tool useful, please consider sponsoring this project financially via https://opencollective.com/openapi_generator or directly to Kay Schecker (the author of this tool) :pray:
You need to execute openapi-generator-cli
instead of openapi-generator
from now on.
To make that happen, a version management was added to the package.
The first time you run the command openapi-generator-cli
the last stable version
of OpenAPITools/openapi-generator is downloaded by default.
That version is saved in the file openapitools.json. Therefore you should include this file in your version control, to ensure that the correct version is being used next time you call the command.
If you would like to use a different version of the OpenAPITools/openapi-generator, you could change it by using one of the following commands:
openapi-generator-cli version-manager list
openapi-generator-cli version-manager set <versionTags...>
You will now be able to configure the code generation in openapitools.json. This makes it more convenient to generate code for every file that matches the given glob expression. For more information, please check out the configuration documentation below.
1npm install @openapitools/openapi-generator-cli
or using yarn
1yarn add @openapitools/openapi-generator-cli
After the installation has finished you can run npx openapi-generator-cli
or add a script like this:
1{ 2 "name": "my-cool-package", 3 "version": "0.0.0", 4 "scripts": { 5 "my-awesome-script-name": "openapi-generator-cli generate -i docs/openapi.yaml -g typescript-angular -o generated-sources/openapi --additional-properties=ngVersion=6.1.7,npmName=restClient,supportsES6=true,npmVersion=6.9.0,withInterfaces=true", 6 } 7}
Note the whitespace sensitivity when using multiple additional-properties:
1--additional-properties=ngVersion=6.1.7,npmName=restClient,supportsES6=true,npmVersion=6.9.0,withInterfaces=true
1npm install -g @openapitools/openapi-generator-cli
or using yarn
1yarn global add @openapitools/openapi-generator-cli
After the installation has finished you can run openapi-generator-cli
Mac/Linux:
openapi-generator-cli generate -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /var/tmp/ruby-client
Windows:
openapi-generator-cli generate -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o C:\temp\ruby-client
If you have installed the package locally and executed the command openapi-generator-cli
at least once,
you will find a new file called openapitools.json along with the package.json. Please add this file to your VCS.
Initially the file has the following content:
1{ 2 "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 "spaces": 2, 4 "generator-cli": { 5 "version": "7.8.0" // or the current latest version ;) 6 } 7}
This configuration indicates the following:
Further it is also possible to configure generators, for example:
1{ 2 "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 "spaces": 2, 4 "generator-cli": { 5 "version": "7.8.0", 6 "storageDir": "~/my/custom/storage/dir", // optional 7 "generators": { // optional 8 "v2.0": { // any name you like (just printed to the console log or reference it using --generator-key) 9 "generatorName": "typescript-angular", 10 "output": "#{cwd}/output/v2.0/#{ext}/#{name}", 11 "glob": "examples/v2.0/{json,yaml}/*.{json,yaml}", 12 "additionalProperties": { 13 "ngVersion": "6.1.7", 14 "npmName": "restClient", 15 "supportsES6": "true", 16 "npmVersion": "6.9.0", 17 "withInterfaces": true 18 } 19 }, 20 "v3.0": { // any name you like (just printed to the console log or reference it using --generator-key) 21 "generatorName": "typescript-fetch", 22 "output": "#{cwd}/output/v3.0/#{ext}/#{name}", 23 "glob": "examples/v3.0/petstore.{json,yaml}" 24 } 25 } 26 } 27}
If openapi-generator-cli generate
is called without further arguments, then the configuration
is automatically used to generate your code. 🎉
placeholder | description | example |
---|---|---|
name | just file name | auth |
Name | just file name, but starting with a capital letter | Auth |
cwd | the current cwd | /Users/some-user/projects/some-project |
base | file name and extension | auth.yaml |
path | full path and filename | /Users/some-user/projects/some-project/docs/auth.yaml |
dir | path without the filename | /Users/some-user/projects/some-project/docs |
relDir | directory name of file relative to the glob provided | docs |
relPath | file name and extension of file relative to the glob provided | docs/auth.yaml |
ext | just file extension | yaml |
If you're using a private maven registry you can configure the downloadUrl
and queryUrl
like this:
1{ 2 "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 "spaces": 2, 4 "generator-cli": { 5 "version": "7.8.0", 6 "repository": { 7 "queryUrl": "https://private.maven.intern/solrsearch/select?q=g:${group.id}+AND+a:${artifact.id}&core=gav&start=0&rows=200", 8 "downloadUrl": "https://private.maven.intern/maven2/${groupId}/${artifactId}/${versionName}/${artifactId}-${versionName}.jar" 9 } 10 } 11}
If the version
property param is set it is not necessary to configure the queryUrl
.
In order to use a locally built jar of the generator CLI, you can copy the jar from your local build (i.e. if you were to build
the OpenAPITools/openapi-generator repository it would be in ~/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar
) into ./node_modules/@openapitools/openapi-generator-cli/versions/
and change the version
in the openapitools.json
file to the base name of the jar file.
E.g.:
1cd openapi-generator 2./mvnw clean package 3cp ./modules/openapi-generator-cli/target/openapi-generator-cli.jar /your/project/node_modules/@openapitools/openapi-generator-cli/versions/my-local-snapshot.jar
and then:
1{ 2 "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 "spaces": 2, 4 "generator-cli": { 5 "version": "my-local-snapshot", 6 } 7}
SNAPSHOT
buildChange your openapitools.json
to:
1{ 2 "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 "spaces": 2, 4 "generator-cli": { 5 "version": "7.9.0-20240829.123431-22", 6 "repository": { 7 "downloadUrl": "https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.9.0-SNAPSHOT/openapi-generator-cli-${versionName}.jar" 8 } 9 } 10}
Example is with a snapshot of 7.9.0
, please change the version
and downloadUrl
accordingly.
You can find all snapshots here.
cmd | v3.0 runs | v2.0 runs |
---|---|---|
openapi-generator-cli generate --generator-key v3.0 | yes | no |
openapi-generator-cli generate --generator-key v3.0 v2.0 | yes | yes |
openapi-generator-cli generate --generator-key foo | no | no |
1{ 2 "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 "spaces": 2, 4 "generator-cli": { 5 "useDocker": true 6 } 7}
If useDocker
option is used, the spec file gets mounted to path /local/<your-spec-file-location>
within container. So, if you would configure spec file as
-i openapi/my-api.yml
if running locally, with useDocker option set, you would have to configure it like this: -i /local/openapi/my-api.yml
.
Custom generators can be used by passing the --custom-generator=/my/custom-generator.jar
argument.
Please refer to the official openapi-generator docs for more information about the possible arguments and a detailed usage manual of the command line interface.
1npm install @openapitools/openapi-generator-cli@previous 2npm i @openapitools/openapi-generator-cli@1.0.18-4.3.1
or using yarn
1yarn add @openapitools/openapi-generator-cli@previous 2yarn add @openapitools/openapi-generator-cli@1.0.18-4.3.1
Please leave a star.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
30 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 6/11 approved changesets -- score normalized to 5
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More