19

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.

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
some bits flipped
  • 2,592
  • 4
  • 27
  • 42
  • https://hub.docker.com/r/bentheadset/bentheadset-swagger-codegen-3.0.0/ pulls the .jar published in the link above ( https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/3.0.0-SNAPSHOT/ ) – some bits flipped Aug 16 '17 at 19:46
  • 1
    OpenAPI 3.0 support is being worked on. Please refer to the branch (https://github.com/swagger-api/swagger-codegen/tree/3.0.0_enhancements) for progress. – William Cheng Nov 21 '17 at 15:30
  • @WilliamCheng Your link has gone dead. – tchrist Sep 25 '18 at 14:45
  • @tchrist thanks for reporting the broken link. I'm no longer involved in Swagger Codegen. Please refer to my answer below for more information. – William Cheng Sep 25 '18 at 14:48
  • Please see this slightly newer question re using the swagger codegen maven plugin on an OpenAPI 3.0 spec bcos it has working answers: https://stackoverflow.com/questions/49616529/swagger-codegen-with-maven-plugin-for-openapi-3-0 – chrisinmtown May 02 '19 at 14:58

2 Answers2

16

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

William Cheng
  • 10,137
  • 5
  • 54
  • 79
3

Swagger-codegen 3.0.0 snapshots now include a limited number of targets for code generation from OpenAPI 3.0 definitions. https://github.com/swagger-api/swagger-codegen/issues/6598#issuecomment-333428808

There is an alternative experimental implementation of the codegen engine, using the original swagger-codegen 2.x templates, written in Node.js: https://github.com/mermade/openapi-codegen - if your language is not yet supported, a config file just needs to be created for it mapping the template files to outputs.

MikeRalphson
  • 2,247
  • 2
  • 15
  • 16