[17.0.0.1 and later]

列出集合体中所有公共 RESTful API

使用集合体服务查询,发现有关整个集合体中所有公共 RESTful API(服务)的 API 文档。此查询以列表格式提供文档。

此列表包含每个服务的摘要,例如,服务的名称、版本、描述和当前部署此服务的主机列表。此列表实时更新,向集合体成员添加服务或从其中移除服务时会更改。此列表包含来自任何集合体成员的服务,不管成员是 Liberty、Docker 和 Liberty、LoopBack® 还是 Docker 和 LoopBack 服务器都会包含在内。

集合体服务查询的缺省 URL 为 http://controller_host:controller_http_port/api/collective/registry

开始之前

/api/collective/registry API 在 Liberty API 发现功能部件中。要查询集合体中公共服务,必须首先将 apiDiscovery-1.0 功能部件添加到集合体控制器 server.xml 文件,然后在 Liberty REST 端点中公开 Swagger 2.0 文档。 完成在 Liberty 服务器上发现 REST API 文档中过程的步骤 1 和步骤 2。

过程

  1. 将浏览器指向 http://controller_host:controller_http_port/api/collective/registry URL。

    controller_hostcontroller_http_port 替换为集合体控制器的值。

  2. 可选: 在控制器 server.xml 文件中更改具有 publicURL 属性的公共端点的 URL。

    可以使用 server.xml 文件的 apiDiscovery 元素中的 publicURL 属性配置 http://controller_host:controller_http_port/api/collective/registry URL 的 api 部分。

    例如,可以使用 publicURL 属性,将集合体 RESTful 服务注册表的位置从 /api/collective/registry 更改为 /services/collective/registry

    1. <apiDiscovery publicURL="/services"/> 添加到控制器 server.xml 文件。
    2. 将浏览器指向 http://controller_host:controller_http_port/services/collective/registry URL。

    有关 publicURL 属性的更多信息,请参阅 在 Liberty 服务器上发现 REST API 文档

结果

查询提供公共服务的列表:

{  
   "services":[
      {  
         "service":"/airlines/booking",
         "title":"Booking REST APIs",
         "description":"A microservice exposing booking APIs for various airlines.",
         "version":"1.0.0",
         "hosts":[  
            "vm001:9081",
            "vm002:9082"
         ]
      },
      {  
         "service":"/flight/status",
         "title":"Flight Status REST APIs",
         "description":"A microservice exposing flight status APIs for various airports.",
         "version":"1.0.1",
         "hosts":[  
            "vm003:9085"
         ]
      },
      {  
         "service":"/tourism",
         "title":"Tourism REST APIs",
         "description":"A microservice exposing tourism information for various popular destinations.",
         "version":"2.0.0",
         "hosts":[
            "vm004:9443"
         ]
      }
   ]
}

用于指示主题类型的图标 任务主题

文件名:twlp_api_discovery_list_query.html