...
Swagger-based interactive documentation allows you to try out APIs from the documentation itself. It is a Java Script client that runs in the API Store and makes Java Script calls from the Store to the API Gateway. Since the API Store and Gateway run on two different ports, you must enable cross-origin resource sharing (CROSCORS) between the two using CORS configuration in <APIM_HOME>/repository/conf/api-manager.xml
file. Given below is a sample configuration of CROS CORS and a description of its XML elements:
...
- In the API Publisher, go to the Doc tab of
FindFeeds
API to see its API definition. Click Edit Content. API definition contains the JSON representation of the API. You can easily modify existing content, add/remove elements, change paths and parameters etc. using the JSON editor.
Info - API Manager 1.5.0 onwards has integrated JSONMate as the editor for modifying the API Definition.
- For the Swagger specification of API declaration, see https://github.com/wordnik/swagger-core/wiki/API-Declaration.
There are Two ways to modify the API Defnition. You can either use the Text Editor given, or the graphical tree editor.
By default, all the POST and PUT operations have the
Payload
parameter, which you can use to send any payload when invoking the API. The GET, DELETE operations haveQuery parameters
, which you can use to send URL-appended parameters (ex: v=2&length=200). You can also add named parameters. For example, to modify the path of the API created above with a parameter, edit the path and add the relevant parameter.Let's say that you want to send a query parameter called 'v' in the GET request of
top_rated
resource. The screenshot below showspath
modified with a parameter. Also, the default Query Parameter is changed to a parameter calledv
.Text Editor
You can just modify the JSON content according to Swagger Specification.
Graphical Editor
If you would like to use Shown below is an example of the graphical editor here is the way to do. To add new elements, click Add New Value and provide the value. To delete elements, delete the value of Key. For example, if you delete the Key value named
description
, that element will be deleted.Also be sure to modify descriptions, notes, summary on each of the operations.
Once the modifications are done, save.
Log in to the API Store and click on GET operation to expand it. There you can enter the parameters and try it out.
Next, see API Versioning.