此内容没有您所选择的语言版本。

13.24. Swagger Translator


13.24.1. Swagger Translator

The Swagger translator, known by the type name "swagger" relationally exposes the Swagger data sources and uses the Teiid WS resource adapter for making web service calls.
You can use Swagger similarly to any other source in Red Hat JBoss Data Virtualization. The metadata import is supported through the translator, the metadata is imported from the source system’s swagger.json file and then the API from this file is exposed as stored procedures in Red Hat JBoss Data Virtualization. The source system can then be queried by executing these stored procedures in the system.
Here is a sample VDB that can read metadata from the Petstore reference service found at http://petstore.swagger.io/:
<vdb name="petstore" version="1">
    <model visible="true" name="m">
        <source name="s" translator-name="swagger" connection-jndi-name="java:/swagger"/>
    </model>
</vdb>
Copy to Clipboard Toggle word wrap
This is what the resource-adapter configuration file will look like:
<resource-adapter id="swagger">
    <module slot="main" id="org.jboss.teiid.resource-adapter.webservice"/>
    <transaction-support>NoTransaction</transaction-support>
    <connection-definitions>
        <connection-definition class-name="org.teiid.resource.adapter.ws.WSManagedConnectionFactory" jndi-name="java:/swagger" enabled="true" use-java-context="true" pool-name="teiid-swagger-ds">
            <config-property name="EndPoint">
                http://petstore.swagger.io/v2
            </config-property>
        </connection-definition>
    </connection-definitions>
</resource-adapter>
Copy to Clipboard Toggle word wrap
Once you configure the resource-adapter and deploy the VDB successfully, you can connect to the deployed VDB using the JDBC driver and issue SQL statements like this:
EXEC findPetsByStatus(('sold',))
EXEC getPetById(1461159803)
EXEC deletePet('', 1461159803)
Copy to Clipboard Toggle word wrap

Note

This translator has no execution properties.
Expand
Table 13.23. Importer Properties
Name Description Default Value
useDefaultHost Use the default host specified in the Swagger file; when false uses the endpoint in the resource-adapter. True
preferredScheme Preferred Scheme to use when Swagger file supports multiple invocation schemes like http and https. null
preferredProduces Preferred Accept MIME type header. This should be one of the Swagger 'produces' types; application/json
preferredConsumes Preferred Content-Type MIME type header. Tthis should be one of the Swagger 'consumer' types. application/json
Here are example importer settings that allow you to avoid calling the host defined in the swagger.json file
<property name="importer.useDefaultHost" value="false"/>
Copy to Clipboard Toggle word wrap
This adapter uses a Web Service Data Source.

Note

Native or direct query execution is not supported through the Swagger translator. However, you can use the Web Services Translator’s invokehttp method to issue a REST-based call and parse the results using SQLXML.
The translator has these limitations:
  • The "application/xml" mime type is not supported in either "Accept" and "Content-Type".
  • File and Map properties are currently not supported, and therefore multi-part payloads are also not supported
  • Security metadata is not currently supported.
  • Custom properties that start with "x-" are not supported.
  • Schema with "allof", "multipleof", and "items" from JSON schema are not supported.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat