com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Generating an API using Swagger

This feature is available for WSO2 EI 6.5.0 from the 3rd of September 2019 (2019-09-03) onwards as a WUM update.  For more information, see Updating WSO2 Products.

Follow the instructions given below to generate a REST API using a Swagger definition and then try it out from the Swagger UI. Alternatively, you can create a REST API using WSO2 Integration Studio.

Prerequisites

To use the Swagger UI, you need to configure CORS in the ESB server.

Open the synapse.propertiesfile (stored in the <EI_HOME>/conf/ directory) and add the following configuration. Note that the ​synapse.rest.CORSConfig.Access-Control-Allow-Origin property points to https://localhost:9443 as the value, and thereby enables CORS for localhost. You can add all the required URLs as a comma-separated list.

synapse.rest.CORSConfig.enabled=true
synapse.rest.CORSConfig.Access-Control-Allow-Origin=https://localhost:9443​,http://localhost:8280
synapse.rest.CORSConfig.Access-Control-Allow-Headers=content-type

Step 1: Generating the API

Follow the steps given below to generate the API using Swagger.

  1. Start the ESB profile of WSO2 EI.
  2. Open the management console of WSO2 EI from https://10.100.5.12:9443/carbon/.
  3. Go to the ​Maintab and click API to open the Deployed APIs screen.
  4. Click Generate APIas shown below.

  5. The Swagger UI will then open. The Swagger definition of a sample API is shown on the left and the details of the API is shown on the right.

  6. You can edit the Swagger definition or import a new one:
    1. Use the Edit menu on the Swagger editor to edit the current definition.

    2. Use the File menu of the Swagger editor to import your own Swagger definition. You can point to a URL or you can upload a new file: 

  7. Click Generate API to generate the API as depicted below.

    The synapse configuration of the generated API will then be shown.
  8. Save the API. You are now redirected to the Deployed APIssection.

     
  9. The following options are available for the API: 
    • 1 - The Swaggeroption directs to the Swagger definition of the API.
    • 2 - The Try This APIoption directs to the TryIt tool, which allows you to test the API.

Step 2: Editing the API (Optional)

Once you have generated the API using Swagger, you have the option of editing the API as follows:

  1. Click Edit to open the Edit API view, and then click Edit Swagger to view the Swagger editor.
  2. Once you finish editing, click Apply Changes and you will be redirected to the Edit API view.

  3. Save the changes in the Edit API view. You will now be directed back to the Deployed APIsview.

Step 3: Trying out the API

Let's test the API by executing a sample request:

  1. In the Deployed APIs view, click Try This API for the API. The Swagger Try It tool opens in a new browser tab. 

    Note that this UI is accessible even without signing in to WSO2 EI.



  2. Click a service of the API to view the details.
  3. Click ​Try it out​
    You can then edit the payload, set the content type of the request and response, and then click Execute to send the request.

  4. The response will be shown along with other details such as the cURL command used, request URL, response code, etc.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.