Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run swagger-codegen for OpenAPI 3.0.0

looks like official swagger for openapi specification V3 support is near release https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/, and the swagger-codegen has 3.0.0 support developed and passing some level of testing https://github.com/swagger-api/swagger-codegen on the 3.0.0 branch

I have a swagger spec (generated from my existing 2.0 spec via https://github.com/mermade/swagger2openapi, output looks good)

Is there an easy way to run the swagger-codegen without having to package the jar myself?

  • this is the single result i found: https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/3.0.0-SNAPSHOT/ but running that seems to be broken (from the output, possibly actually running 2.0 not 3.0.0?):

[main] INFO io.swagger.parser.Swagger20Parser - reading from /input/myspec.openapi3.json [main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found. Exception in thread "main" java.lang.RuntimeException: missing swagger input or config! at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:685) at io.swagger.codegen.cmd.Generate.run(Generate.java:285) at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

It looks like the swagger-codegen repo has a somewhat supported way to run a docker container after you build; I'm just hoping/guessing there is a supported way to do this without needing to compile locally, as I need to set this up in several places.

like image 873
some bits flipped Avatar asked Aug 16 '17 15:08

some bits flipped


1 Answers

OpenAPI Generator (found by top contributors of Swagger Codegen) supports both OpenAPI specification v2 and v3.

You can use the docker images, Java JAR (SNAPSHOT), Brew or npm to give it a try.

For more information about OpenAPI Generator, please refer to the project's README

If you need any help, please open an issue and we'll look into it.

UPDATE: 1st stable version 3.0.0 has been released: https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.0

like image 152
William Cheng Avatar answered Oct 03 '22 06:10

William Cheng