Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger codegen failed: missing swagger input or config

I have this json file and I have been trying to create models and API code through swagger codegen. This has not been quiet effective as it throws error.

Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
    at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:735)
    at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
    at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

The swagger docs version is 1.2. And I am using swagger-codegen version 2.4.0.

java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i ./json/docs.json -l python -o C:/Users/sk/projects/generated-sdk
like image 722
Skaranjit Avatar asked Jun 12 '18 05:06

Skaranjit


People also ask

How do I get swagger codegen?

Swagger Codegen is available for download in the GitHub repository, or can be generated for any new or existing OpenAPI-defined API in the integrated SwaggerHub platform.

What is codegen in swagger?

The Swagger Codegen is an open source code-generator to build server stubs and client SDKs directly from a Swagger defined RESTful API. The source code for the Swagger Codegen can be found in GitHub.

How do I run swagger codegen on Windows?

Download the Swagger Codegen JAR File Download the latest version of the Swagger Codegen JAR 2.3. 0+. Windows users can use Invoke-WebRequest in PowerShell 3.0+ (e.g., Invoke-WebRequest -OutFile swagger-codegen-cli. jar http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.3.1/swagger-codegen-cli-2.3.1.jar).

What is swagger codegen ignore?

# Swagger Codegen Ignore. # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen. # Use this file to prevent files from being overwritten by the generator.


1 Answers

In the yaml file, if you do not strictly have the indent, you can get the error like this. For swagger-codegen-cli-2.1.6.jar, the error message won't tell you which row is wrong. (Just not sure whether this get fixed in the newer version. )

like image 118
Peter Avatar answered Sep 18 '22 02:09

Peter