如何在 Maven 中将多个 OpenAPI 3.0 规范文件合并为一个?
在使用 Spring Boot 的 Maven 项目中,有多个 OpenAPI 3.0 规范文件。一个规范定义了所有 HTTP 错误 (errors.yml),并且 error.yml 的组件在其他规范中引用。 我想生成一个输出规范,其中包含 error.yml 的所有组件。
输入规范:
schema:
$ref: "errors.yml#/components/schemas/Error"
希望的输出规范:
schema:
$ref: "#/components/schemas/Error"
...
Error:
...
我可以使用 swagger-codegen-cli 来完成:
java -Dfile.encoding=UTF-8 -jar swagger-codegen-cli-3.0.33.jar generate -l openapi-yaml -i search-api-contract/target/expert_api.yml -o . -DoutputFile=search-api-contract/target/expert_api.yml
如何使用 Maven pom.xml 生成一个规范?
In a Maven project with Spring Boot, there are several OpenAPI 3.0 specification files. One spec defines all HTTP errors (errors.yml), and the components of errors.yml are referenced in other spec.
I want to generate an output spec with all components of errors.yml inside.
Input spec:
schema:
$ref: "errors.yml#/components/schemas/Error"
Wished output spec:
schema:
$ref: "#/components/schemas/Error"
...
Error:
...
I can do it with swagger-codegen-cli:
java -Dfile.encoding=UTF-8 -jar swagger-codegen-cli-3.0.33.jar generate -l openapi-yaml -i search-api-contract/target/expert_api.yml -o . -DoutputFile=search-api-contract/target/expert_api.yml
How to generate one spec with Maven pom.xml?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Swagger Codegen 有一个 Maven 插件< /a>.你可以这样使用它:
Swagger Codegen has a Maven plugin. You can use it like this: