Loading an API Gateway Specification
Learn how to load an API Gateway Specification using the HTTP Admin API.
Loading an API you have defined using the API Gateway Specification is very easy you just need to know the location of your file and use the HTTP Admin API.
Assumptions
The following instructions assume the following:
- Your API Specification file is called
my_api.json - Your API Specification
idproperty has the valuecom.example.my_api - Bondy is running at
localhoston port18081
Host and Port
Port 18081 is where the reserved admin listener serves the Admin API by default — no configuration is needed. If your bondy.conf declares its own listeners.admin.* block, use the port it states; see the Network Listeners Reference.
Loading the API Specification
The following command will load the API Specification, validate it and if successful it will be compiled and activate it.
curl -X "POST" "http://localhost:18081/services/load_api_spec" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Accept: application/json; charset=utf-8' \
--data-binary "@my_api.json"Cluster deployments
If this node is part of a Bondy cluster, the API will be automatically replicated and activated in all nodes.
Verifying the API Specification has been loaded
If the previous command didn't fail the API has been loaded and activated. However, to be entirely sure you can use the following command which should retrieve the API Specification.
curl -X "GET" "http://localhost:18081/api_specs/com.example.my_api"A stored specification is not always served. To check that a node serves it, call the WAMP procedure bondy.http_gateway.api.status on that node:
wick --url ws://localhost:18080/ws \
--realm com.leapsight.bondy \
call bondy.http_gateway.api.statusFind the element whose id is your specification's id. The status active means that the node serves the specification.
If the status is pending_realm, the specification's realm does not exist on the node. Create the realm. The node installs the specification's routes at its next rebuild after the realm appears.
If the status is rejected, the specification failed to parse, and reason describes the failure. Correct the specification and load it again.