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

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"        ...

Adding error sequence to a custom sequence

In my previous posi i explained how to call an endpoint using the call mediator. Usually when errors are thrown from the call mediator we can handle them using a custom sequence. When call mediators fails the execution stops hence handling errors is very essential. For this post I will be modifying the same sequence which i created in the blog post [1] The change which we need to do is we need to modify the sequence definition to map with the error sequence as shown below. You can find the modified sequence here . <sequence xmlns="http://ws.apache.org/ns/synapse" name="countrySequenceWithError" onError="countryErrorSequence"> <property name="uri.var.countryCode" expression="$url:countryCode"/> <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>     <call blocking="true">         <endpoint>             <http method="get" uri-temp...

Adding custom error messages within a custom sequence in API Manager

Overview You can add custom error messages for an API by following the post [1] but when the error is thrown inside the custom in or out sequence we add as the mediation extension this custom error sequence which we specify for the API does not get invoked. Therefore we need to specify the error sequence seperately for the custom sequence. This blog will explain how to carry out this use case. Let's get started To demonstrate this I will be using the call mediator inside the custom sequence. Since when an invalid endpoint is invoked with the call mediator it would generate an error in the API Manager which would be received inside our custom sequence. 1) You can follow my previous tutorial [2] to get a better understanding and configurations needed to use the call mediator using wso2 api manager 1.10.0. Create the API as mentioned in the sequence above and subscribe and generate keys for the API in the store. 2) Now what we are going to do is, we are going to provide an ...