招摇编辑器
将您的 OpenAPI 2.0 定义粘贴到https://editor.swagger.io https://editor.swagger.io并选择编辑 > 转换为 OpenAPI 3从菜单中。
招摇转换器
将 OpenAPI 2.0 和 Swagger 1.x 定义转换为 OpenAPI 3.0。
https://converter.swagger.io/api/convert?url=OAS2_YAML_OR_JSON_URL
这将为您提供 JSON。如果您需要 YAML,请使用以下内容发送请求Accept: application/yaml
header:
curl "https://converter.swagger.io/api/convert?url=OAS2_YAML_OR_JSON_URL" -H "Accept: application/yaml" -o ./openapi.yaml
API文档:https://converter.swagger.io https://converter.swagger.io
GitHub 仓库:https://github.com/swagger-api/swagger-converter https://github.com/swagger-api/swagger-converter
Swagger Codegen 版本 3.x
还可以将 OpenAPI 2.0 和 Swagger 1.x 定义转换为 OpenAPI 3.0。 Swagger Codegen 有一个 CLI 版本,Maven插件 https://github.com/swagger-api/swagger-codegen/tree/3.0.0/modules/swagger-codegen-maven-plugin, Docker 镜像 https://github.com/swagger-api/swagger-codegen/tree/3.0.0#public-pre-built-docker-images.
这是使用命令行版本的示例(您可以从以下位置下载最新的 JAR)梅文中心 https://mvnrepository.com/artifact/io.swagger.codegen.v3/swagger-codegen-cli)。写出整个命令在一条线上. Use openapi-yaml
获取 YAML 或openapi
获取 JSON。
java -jar swagger-codegen-cli-3.0.19.jar generate
-l openapi-yaml
-i https://petstore.swagger.io/v2/swagger.yaml
-o OUT_DIR
GitHub 仓库:https://github.com/swagger-api/swagger-codegen https://github.com/swagger-api/swagger-codegen