-
Language:
English
-
Language:
English
Red Hat Training
A Red Hat training course is available for Red Hat JBoss Data Virtualization
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>
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>
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)
Note
This translator has no execution properties.
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"/>
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.