Quarkus:提供多个 OpenApi/Swagger-UI 端点 [英] Quarkus: Provide multiple OpenApi/Swagger-UI endpoints

查看:84
本文介绍了Quarkus:提供多个 OpenApi/Swagger-UI 端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在版本 0 中有一个带有一些端点的 rest api.我想用一个新的更通用的端点(版本 1,相同的路径,但不同的实现和不兼容的参数)替换当前的端点,但需要保留旧的跑了一会儿.

I have an rest api with some endpoints in version 0. I want to replace the current endpoints with a new more generic one (version 1, same path, but different implementation and incompatible params), but need to keep the old ones running for while.

问题是:Quarkus 是否有可能提供两个 OpenApi 定义和两个 Swagger UI 页面?

The Question is: Is it possible for Quarkus to provide two OpenApi definitions and two Swagger UI pages?

在我的项目中,我包含了 openapi 依赖项,并让 Quarkus 生成 OpenApi 定义.是否可以将版本 0 的端点分组为一个定义,其余为另一个定义?
我有一个可以浏览到 example.com/v0/docs/或 example.com/v1/docs/的设置.在不同版本中启动 API 的两个实例很容易,但我认为不更改端口是不可能的.我希望所有端点都可以在同一个端口上访问.
遗憾的是,我找不到 quarkus 场景的示例.

In my project I included the openapi dependency and let Quarkus generate the OpenApi definition. Is it possible to group the endpoints of version 0 for the one definition and the rest for another one?
I have a setup in mind where one could browse to example.com/v0/docs/ or example.com/v1/docs/. Starting two instances of the API in different versions would be easy, but I think it's not possible without changing the port. I would prefer to have all endpoints accessible on the same port.
Sadly I couldn't find an example for that scenario with quarkus.

如果这是不可能的,在一个定义中包含 v0 和 v1 端点是否是一个好习惯?对我来说看起来很奇怪.但也许那只是我.

If that won't be possible, would it be good practice to have v0 and v1 endpoints in one definition? It looks weird to me. But maybe that's just me.

推荐答案

据我所知,答案是否定的.

The answer is no, as far as I can see.

Quarkus 降低了部署和操作的复杂性,但代价是您无法获得功能齐全的应用服务器为您提供的所有自由(例如在不同 URL 下部署同一应用的两个版本).

Quarkus reduces complexity of deployment and operation but the price is that you do not have access to all the freedom that a full featured application server gives you (like deploying two versions of the same application under different URLs).

但是:由于 Quarkus 是容器优先",您应该能够将 v0 和 v1 部署在不同的容器中,侦听不同的端口但被上游 Web 服务器合并到相同的 URL 结构中像 Apache 或 NGINX.

But: Since Quarkus is "containers first", you should be able to deploy v0 and v1 in different containers, listening to different ports but being merged into the same URL structure by an upstream web server like Apache or NGINX.

在一个 Quarkus 应用程序中使用两个版本似乎会带来很多麻烦,例如关于正确版本控制您的应用程序.

Having both versions in one Quarkus applications seems to invite lots of trouble, e.g. about versioning your application(s) correctly.

这篇关于Quarkus:提供多个 OpenApi/Swagger-UI 端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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