...
An API creator uses the API Publisher to create and publish APIs to the API Store. Let's create an API and add interactive Swagger-based documentation to it.
In this guide, we work with a service exposed by the Cdyne services provider (www.cdyne.com). We use their phone validation service, which has SOAP and REST interfaces and is documented using a WSDL file. This service is documented at : http://wiki.cdyne.com/index.php/Phone_Verification.
- Open the API Publisher (
https://<hostname>:9443/publisher)
and log in asapicreator
. Click the Add link and provide the information given in the table below. Click Implement once you are done.
Field Sample value Name PhoneVerificationContext/phoneverifyVersion 1.0.0 Visibility Public Resources URL pattern CheckPhoneNumber Request types GET, POST, OPTIONS Give the following information in the Implement tab that opens and click Manage once you are done.
Field Sample value Implementation method Backend Endpoint type HTTP Production endpoint This sample service has two operations as
CheckPhoneNumber
andCheckPhoneNumbers
. Let's useCheckPhoneNumber
here.
In this guide, we work with a service exposed by the Cdyne services provider. We use their phone validation service, which has SOAP and REST interfaces. Endpoint is http://ws.cdyne.com/phoneverify/phoneverify.asmxTo verify the URL, click the Test button next to it.This sample service has two operations as
CheckPhoneNumber
andCheckPhoneNumbers
. Let's useCheckPhoneNumber
here.Endpoint security scheme Non Secured (If secured, user is asked for credentials of the backend service) Click Manage to go to the
Manage
tab and provide the following information.Field Value Description Tier Availability Bronze/Gold/Silver/Unlimited The API can be available at different level of service; you can select multiple entries from the list. At subscription time, the consumer chooses which tier they are interested in. Tip Tip: For resources that have methods requiring authentication (i.e., Auth Type is not NONE), you set None as the Auth type of
OPTIONS
to support CORS (Cross Origin Resource Sharing) between the API Store and Gateway.Once you are done, click Save. Before we publish the API, let's document its parameters.
Adding API documentation
After creating saving the API, click on its icon thumbnail in the API Publisher to open its details. Select the Docs tab.
Click Add New Document link.
Documentation can be providedit.
Click on the API's Docs tab and note that you can create documentation inline, via a URL or as a file. For inline documentation, you can edit the content directly from the API publisher interface. You get several documents types:
- How To
- Samples and SDK
- Public forum / Support forum (external link only)
- API message formats
- Other
Click the Add New Document link.
- Select the How To type, a name for the document and a short description, which will appear in the API Store. Select inline or provide a URL.
- Click Add Document.
Once the document is added, click Edit Content link, which opens an embedded editor to edit the document contents.
...
Adding interactive documentation
The API Manager provides facility to add interactive documentation support through the integration of Swagger. Swagger is a specification and a complete framework implementation for describing, producing, consuming, and visualizing RESTful Web services. In Swagger, when APIs are described in simple static JSON representation, they can be loaded through the Swagger UI, which in turn provides the interactive documentation.
When an API is created, the JSON representation of that API is automatically generated and saved into the registry as API definition. This definition describes the API with the information provided at the API creation level. You can customize the automatically generated API definition as follows:
- Click the Edit link right next to the API's name in the API Publisher to open it in the edit mode.
- Click the Edit Swagger Definition button.
When the Swagger definition of the API opens, document the parameters required by the API Console.
For example, thePhoneVerification
API requires a telephone number and a license key. You can document this by adding the following under the parameters section of the GET method:Code Block parameters: - description: Request Body name: body allowMultiple: false required: true type: string paramType: body - description: Give the phone number to be validated name: PhoneNumber type: string required: "True" paramType: query - description: "Give the license key. If you don't have any, enter 0" name: LicenseKey type: string required: "True" paramType: query
- Click Save once the changes are done.
...