Skip to main content

Importing API definition into gateway using swagger.



In this post I will show you how you can publish an API to the API Cloud using a swagger definition. If you do not have an account with the WSO2 Cloud you can read my previous blog post about WSO2 cloud where i have mentioned how you can create a free account with the cloud.


Let's get started. First log in to the WSO2 Cloud and select the API Cloud.
  • Once you select the API Cloud you will be directed to this particular page. This is the API Publisher. Using this you will be able to create and publish APIs and carry out many other tasks related to the management of your API. 

  • In order to import an API definition using swagger you first need to select the ‘Add’ menu item in the left menu bar.
addNewAPI.png

  • After which you will be directed to a page as shown below. Select the first option which is ‘I have an Existing API’. 
  • In the expanded section import the API definitions using a swagger file. In this case you need to upload a swagger file. You can find the swagger file used in this example here. This is a simple phone verification API. 
  • Then click on the ‘Start Creating’ button to start the creation of the API.

addNewAPI2.png
  • You will be directed to the page displayed below. As you can see the methods and details have been displayed using the swagger definitions. 
  • Include the context as /phoneverify and click on the the ‘Next Implement’ option.

addNewAPI3.png

  • Select the Managed API option and you will see the UI as shown below. Here we need to specify the service endpoint for the particular API. 
  • Select the HTTP Endpoint option and provide this value as the production and sandbox endpoints. 
  • Next select the ‘Next Manage >’ button.

addNewAPI4.png

  • In this section select the ‘Tier Availability’ as ‘Gold’ and select both transports HTTP and HTTPS. 
  • Select Save and Publish.
addNewAPI5.png

Now you have successfully imported API definitions using a swagger file and published you API. In my next blog post i will be discussing how to subscribe to an API and also set different rate limits and throttling policies on the APIs.

Comments

Popular posts from this blog

Processing large payloads with the esb script mediator iteratively

Overview WSO2 ESB uses Rhino engine to execute JavaScripts. Rhino engine converts the script to a method inside a Java class. Therefore, when processing large JSON data volumes, the code length must be less than 65536 characters, since the Script mediator converts the payload into a Java object. However, you can use the following alternative options to process large JSON data volumes. The script mediator which is used in ESB is powered by the Rhino engine. Therefore, when processing large JSON data volumes, the code length must be less than 65536 characters which is a limitation in the script mediator being used in the esb versions less than 5.0.0. In ESB 5.0.0 there is a higher capability to process larger payloads using script mediator. In order to process such large payloads we can follow the below two approaches. 1. Replace the javascript tranformation logic using java code by writing a custom mediator. [1] 2. Break down the large payload and execute them as sections using

Exposing a SOAP service as a REST API

In this post i will be explaining how we can transform a SOAP based backend to receive requests in a restful manner through the WSO2 API Cloud. Steps. First log into the WSO2 Cloud and navigate to the API Cloud. In the API cloud select the option to add a new API. We will be creating an API to demonstrate an invocation to the backend soap service ws.cdyne.com/phoneverify/phoneverify.asmx?wsdl Give a name, context and version to the API and add a resource name with a GET Method. The resource name can be anything which you like since we will invoke the actual service usiing a custom sequence. Mention the URI template as indicated in the below screenshot. Next go to the implement tab. And select the endpoint type as HTTP/SOAP Endpoint and specify the endpoint as http://ws.cdyne.com/phoneverify/phoneverify.asmx. There is an important step we need to do here. We need to set the SOAP version for this request. In order to do that we need to select the advanced option for the e

Invoking external endpoints using the call mediator in wso2 api manager

Introduction In API Manager if you need to do any service chaining use cases the call mediator comes in handy. If you need to use the response received by invoking one endpoint and then use it to invoke another endpoint you can use the call mediator in API Manager. The call mediator behaves in a synchronous manner. Hence, mediation pauses after the service invocation and resumes from the next mediator in the sequence when the response is received. You can read more about the call mediator in the wso2 esb documentation [1] . In api manager 1.10.0 the call mediator works in the blocking mode. Prerequisite Before we can use the call mediator in API Manager 1.10.0 we need to make the following changes to some configs. We need to comment the jms transport sender in axis2_blocking_client.xml found in the location APIM_HOME/repository/conf/axis2. This will resolve the jms sender initialization issues.   <!--transportSender name="jms"                      class