如何为 OpenAPI 3.0.0 运行 swagger-codegen [英] How to run swagger-codegen for OpenAPI 3.0.0

查看:36
本文介绍了如何为 OpenAPI 3.0.0 运行 swagger-codegen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来像官方 for 规范 V3 支持即将发布 https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/,并且 swagger-codegen 已经开发了 3.0.0 支持并通过了一定程度的测试 3.0.0 分支上的 rel="noreferrer">https://github.com/swagger-api/swagger-codegen

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

我有一个 swagger 规范(通过 https://github.com/mermade/swagger2openapi 从我现有的 2.0 规范生成,输出看起来不错)

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

有没有一种简单的方法来运行 swagger-codegen 而不必自己打包 jar?

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 - 从/input/myspec.openapi3.json 读取[主] 信息 io.swagger.codegen.ignore.CodegenIgnoreProcessor - 找不到 .swagger-codegen-ignore 文件.线程主"java.lang.RuntimeException 中的异常:缺少招摇输入或配置!在 io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:685)在 io.swagger.codegen.cmd.Generate.run(Generate.java:285)在 io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

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

看起来 swagger-codegen repo 有一种在某种程度上受支持的方式来运行 docker 容器你构建之后;我只是希望/猜测有一种支持的方式来执行此操作,而无需在本地编译,因为我需要在多个地方进行设置.

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.

推荐答案

OpenAPI Generator(由Swagger Codegen) 支持 OpenAPI 规范 v2 和 v3.

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

您可以使用 docker 镜像Java JAR (SNAPSHOT),Brewnpm 试试看.

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

有关 OpenAPI Generator 的更多信息,请参阅项目的 README

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.

更新:第一个稳定版本 3.0.0 已发布:https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.0

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

这篇关于如何为 OpenAPI 3.0.0 运行 swagger-codegen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆