API-jhipster-gateway API 部分中未列出的第一个休息端点 (swagger-ui)

API-first rest endpoint not listed in jhipster-gateway API section (swagger-ui)

使用 jhipster 5.7.2

我创建了一个 api 网关和两个微服务。 在第一个中,我创建了一个实体,它在网关后面完美运行。网关显示生成的实体的 api 个端点。

我生成了第二个微服务,但这次我已经在 yml 文件中定义了一个 api,所以我选择了 'API-first'。 我的 api 是使用 open-api 3 定义的。 我使用 instructions there 成功地为我的 api 生成了代码,并测试了使用 curl 直接调用我的微服务端点:此时它按预期工作。

问题:当我将该微服务放在网关后面时,网关看不到 api。当我进入 api 菜单时,我的微服务显示在下拉列表中,但是当我 select 它时,它没有显示端点。

我在搜索时发现的一件奇怪的事情是,当我直接在我的微服务上调用以下 url 时:http://localhost:8082/v2/api-docs(如微服务的 'welcome page' 中所指出的那样)服务),我得到:

{"swagger":"2.0","info":{"description":"my micro-service API documentation","version":"0.0.1","title":"api-first micro-service API","contact":{},"license":{}},"host":"localhost:8082","basePath":"/"}

当我的 yml 文件声明打开时它说 'swagger 2.0'api 3.0.1。 我搜索并找到 this issue,上面写着:

Swagger UI very old version (2.2.10) is used which does not provide the support for Open API

我虽然 openapi 是问题所在,所以我将 yml 文件重写为 swagger 2.0,最后我遇到了完全相同的问题:微服务 API 有效但似乎对网关。

我开始怀疑这是否只是我这边的问题。

默认情况下,JHipster 将 Swagger 配置为仅列出 API 个以 api 开头的端点。这是在 application.yml 中配置的,更改 default-include-pattern 以包括其他路径。例如,要包含以 /api//expires/ 开头的端点,您可以使用以下内容:

swagger:
    default-include-pattern: /(api|expires)/.*