在jhipster-gateway API部分(swagger-ui)中未列出的API-first rest端点 [英] API-first rest endpoint not listed in jhipster-gateway API section (swagger-ui)

查看:272
本文介绍了在jhipster-gateway API部分(swagger-ui)中未列出的API-first rest端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jhipster 5.7.2

Using jhipster 5.7.2

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

I created an api-gateway, and two micro-services. In the first one, I created an entity and it works perfectly behind the gateway. The gateway displays the api endpoints for the generated entity.

我生成了第二个微服务,但是这次我已经在yml文件中定义了一个api,所以我选择了"API-first". 我的api是使用open-api 3定义的. 我使用那里的指令成功地为我的api生成了代码,并且测试了使用curl直接调用我的微服务终结点:在这一点上,它按预期工作.

I generated the second micro-service but this time I had already an api defined in a yml file so I chose 'API-first'. My api was defined using open-api 3. I successfully generated the code for my api, using the instructions there, and tested calling direcly my micro-service endpoint using curl : it worked as expected at this point.

问题:当我将微服务放在网关后面时,网关看不到api.当我进入api菜单时,我的微服务会显示在下拉列表中,但是当我选择它时,它不会显示任何端点.

The problem : when I put that micro-service behind the gateway, the gateway does not see the api. When I go to the api menu, my micro-service shows in the dropdown but when I select it, it shows no endpoints.

搜索时发现的一件奇怪的事情是,当我直接在微服务上调用以下网址时: http://localhost:8082/v2/api-docs (在微服务的欢迎页面"中已指出),我得到了:

One weird thing I found while searching is that when I call the following url on my micro-service directly : http://localhost:8082/v2/api-docs (as pointed in the 'welcome page' of the micro-service), I get :

{"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文件声明openapi 3.0.1时,它显示为"swagger 2.0". 我搜索发现此问题,它说:

It says 'swagger 2.0' when my yml file declared openapi 3.0.1. I searched and found this issue, which says :

Swagger UI使用了非常旧的版本(2.2.10),该版本未提供 对Open API的支持

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可以工作,但网关似乎不可见.

I though openapi was the problem, so I rewrote the yml file to swagger 2.0 and finally I have the same exact problem : micro-service API works but seems not visible to the gateway.

我开始怀疑这只是我个人的问题.

I'm starting to wonder if it's a problem on my side only.

推荐答案

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

By default, JHipster configures Swagger to only list API endpoints beginning with api. This is configured in application.yml, change default-include-pattern to include other paths. For example, to include endpoints beginning with either /api/ or /expires/, you can use the following:

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

这篇关于在jhipster-gateway API部分(swagger-ui)中未列出的API-first rest端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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