swagger-codegen 未被识别为内部或外部命令

swagger-codegen is not recognized as an internal or external command

我正在尝试在我的电脑上配置 swagger,以便使用它。我面临一个无法识别 swagger-codegen 的问题。这是我想在命令行上执行的命令:

swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location> -t <templates path>

这是我基于时的来源:Generate static docs with swagger

请帮帮我!

在 Windows 上,假设您从此处下载了独立的 swagger-codegen-cli-2.2.2.jar
http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.2/swagger-codegen-cli-2.2.2.jar

您可以 运行 如下:

java -jar C:\path\to\swagger-codegen-cli-2.2.2.jar generate -i http://petstore.swagger.io/v2/swagger.json -l html2 -o C:\petstore\html2

您的原始示例缺失 java -jar。 Codegen 是通过 Java 启动器 运行 因为它是一个 JAR 文件而不是一个独立的 .exe 文件。