VMware Tanzu GemFire Developer REST APIs are integrated with the Swagger™ framework. This framework provides a browser-based test client that allows you to visualize and try out Tanzu GemFire REST APIs.
Swagger application JARs are included in the Tanzu GemFire REST application WAR; you do not need to install any additional libraries to use Swagger.
The following example demonstrates how to access the Swagger UI to browse the APIs.
Start a Tanzu GemFire Locator and a Developer REST API-enabled server as described in Setup and Configuration. Specify an
http-service-port for the developer REST service, as the default port, 7070, is already taken by the locator. For example:
gfsh>start locator --name=locator1 Starting a Tanzu GemFire Locator in /Users/admin/apache-geode-1.2.0/locator1... .... gfsh>start server --name=server1 --start-rest-api=true \ --http-service-bind-address=localhost --J=-Dgemfire.http-service-port=8080
To access Swagger, open a browser and enter the following URL. For example:
The following Web page appears:
Using gfsh, create one or more regions on the REST API server. For example:
gfsh>create region --name=region1 --type=REPLICATE --key-constraint=java.lang.String Member | Status ------- | ------------------------------------------ server1 | Region "/region1" created on "server1"
In Swagger, click on region : region CRUD operations to list all the available endpoints for accessing regions.
In the list of region endpoints, click on the GET /v1 endpoint link. The page displays additional request and response information about the API.
Click the Try it out! button. Any regions you added in step 5 are returned in the response body.
Add an entry to the region by expanding the POST /v1/ endpoint.
Click the Try it out! button to see the response body and response code.
You can use the Swagger interface to try out additional Tanzu GemFire API endpoints and view sample responses.