API First implementation with a third-party server

Before you begin

  • Ensure that you have the Manage API privilege in webMethods API Gateway.
  • Configure a third-party implementation server for implementing your APIs.

Procedure

  1. Open the menu options and select APIs.
  2. Click Create API to create an API with required API documentation.
  3. Click Policies and define required policies for the API.
  4. Click Enable mocking to generate API mock responses.
  5. Using an external REST client such as Postman or SoapUI, run the following command to search for the API in webMethods API Gateway for implementation.
    ```typescript
    POST http://<webMethods API Gateway host>:<port>/rest/apigateway/search
    {
    "types" : ["api"],
    "scope" : [
    {
    "attributeName" : "maturityState",
    "keyword" : "ToBeImplemented"
    }
    ]
    }
    ```
    The maturityState parameter in the above command is used search for APIs based on their maturity state. In this use case, we must search for APIs that are to be implemented. Hence, we can provide the ToBeImplemented value for the parameter. This command returns the list of APIs that are yet to be implemented.
  6. Using the API Id of the API that you want to implement, run the following command to retrieve the API contract from webMethods API Gateway.
    ```typescript
    GET http://<host>:<port>/rest/apigateway/apis/{apiId}/
    providerspecification?format=swagger
    ```
    The value for the format parameter can be swagger, raml, or openapi for REST APIs; and wsdl for SOAP APIs.
    >
  7. You can search for an API based on its maturity status in webMethods API Gateway by using the following command.
    > POST http://<webMethods API Gateway host>:<port>/rest/apigateway/search
    > {
    > "types" : ["api"],
    > "scope" : [
    > {
    > "attributeName" : "maturityState",
    > "keyword" : "ToBeImplemented"
    > }
    > ]
    > }
    >
  8. Implement the API in the required implementation server.
  9. After implementation, invoke the REST end point to communicate the API-implemented end point to webMethods API Gateway.
    ```typescript
    PUT http://<webMethods API Gateway host>:<port>/rest/apigateway/apis/{apiId}/implementation
    {
    "maturityState": "string",
    "nativeBaseURLs": [
    "string"
    ]
    }
    ```	
    You can provide required values for the parameters in the above command. 
    For information on parameters, see [List of Parameters used in 
    API Implementation](#list-of-parameters-used-in-api-implementation).
    Example:
    ```typescript
    PUT http://10.2.151.149:5555/rest/apigateway/apis/
    94dfd243-dd54-4d7e-8ba5-396ffaf6fe4e/implementation
    {
    "nativeBaseURLs":["https://10.2.35.125:5556/ws/srvs:Calculator/
    CalculatorHttpSoap11Endpoint",
    "http://10.2.151.149:5555/ws/srvs:Calculator/CalculatorHttpSoap11Endpoint"],
    "maturityStatus" : "Implemented"
    }
    ```

    As an outcome of the REST call, the mocking of the API is disabled and webMethods API Gateway starts requests for the actual implementation.