I installed Swagger CodeGen using the command
npm install swagger-codegen -g
So I should have it installed, but there is some error/glitch
Swagger Codegen is a Java app, so you must have Java installed.
There are two versions of Swagger Codegen - 2.x and 3.x. Use 3.x for openapi: 3.0.0
definitions and 2.x for swagger: '2.0'
.
Download the compiled JAR file:
Codegen 3.x JARs are here: https://oss.sonatype.org/content/repositories/releases/io/swagger/codegen/v3/swagger-codegen-cli/
Codegen 2.x JARs are here: http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/
Look for the file named swagger-codegen-cli-<version>.jar
, e.g. if you need v. 2.3.1:
http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.3.1/swagger-codegen-cli-2.3.1.jar
To run the codegen, use:
java -jar c:\path\to\swagger-codegen-cli-<version>.jar <args>
(You can rename swagger-codegen-cli-<version>.jar
to swagger-codegen-cli.jar
for simplicity.)
Install using Homebrew:
# Codegen 3.x
brew install swagger-codegen
# Codegen 2.x
brew install swagger-codegen@2
Then you can run the codegen as:
swagger-codegen <args>
swagger-codegen@2 <args>
If you don't have Homebrew, download the JAR file from Maven and run it as explained above for Windows.
You can also:
io.swagger
for Codegen 2.x and io.swagger.codegen.v3
for Codegen 3.x.this module doesn't create an executable file when being installed via npm install swagger-codegen -g
, that's why you see the error. Please see https://github.com/swagger-api/swagger-codegen/blob/master/README.md#prerequisites for installation instructions