适配器自动生成

improve this page | report issue


概述

Mobile Foundation 适配器用于执行任何必要的服务器端逻辑,并从后端系统检索信息并将信息传输到客户机应用程序和云服务。

通过适配器的 OpenAPI 规范生成适配器

通过适配器的 OpenAPI 规范(Swagger 规范)自动生成适配器有助于加快完成应用程序开发。 Mobile Foundation 用户现在可以专注于应用程序逻辑,而不必花费精力来创建将应用程序连接到所需后端服务的 Mobile Foundation 适配器。

注:该功能只在 DevKit 中可用。

要使用此功能,针对微服务(或期望的后端服务)的 OpenAPI 规范(.json 或 .yaml)应可用。 通过名为微服务连接器(也称为微服务适配器生成器)的扩展适配器(可从 Mobile Foundation Console 上的下载中心下载)提供适配器生成功能。

注:作为先决条件,请将 JAVA_HOME 变量配置为指向已安装的 JDK 文件夹。

下载中心中适配器生成器的图示

下载微服务适配器生成器适配器并将其部署到 Mobile Foundation 服务器。 已部署的适配器现在将列出在导航窗格中的扩展下。

导航窗格中适配器生成器的图示

单击微服务适配器生成器后会打开页面,用户可在其中提供 OpenAPI 规范(.json 或 .yaml)文件,并且可以选择通过提供的 OpenAPI 规范来生成适配器。

适配器生成器页面的图示

在生成适配器之后,会自动将该适配器下载至浏览器。 然后,需要用户部署生成的适配器以在其应用程序中使用。 选择选项包含适配器源,将适配器源代码和生成的适配器作为 zip 文件下载。 用户可以修改生成的适配器源代码,还可以重新构建并部署适配器。

适配器生成器依赖于 OpenAPI 规范 JSON 的准确性。 如果规范不完整或者不正确,那么生成可能会失败或者可能会导致生成其他与后端微服务的 API 不匹配的 API。

要了解更多信息,请阅读博客帖子:Auto Generate Adapters for Microservices and backend systems from its OpenAPI Specification

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on June 01, 2020