How to run swagger-codegen for OpenAPI 3.0.0

some bits flipped picture some bits flipped · Aug 16, 2017 · Viewed 16.5k times · Source

looks like official for 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?

[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.

Answer

William Cheng picture William Cheng · May 15, 2018

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