Let's use a developer-first approach and host your API, which uses an OpenAPI definition, on WSO2 API Microgateway using the WSO2 Microgateway runtime.
Step 1 - Generate an executable using WSO2 API Microgateway Toolkit
Step 1.1 - Initialize a project
- Navigate to a preferred workspace folder using the command line to set the location that is used to store the Microgateway project.
Create a project named "petstore" by running the following command. This will create the folder structure for the artifacts to be included.
The project is now initialized. A directory with the name "petstore" has been created within the directory where you executed the init command.
Step 1.2 - Build the project
Add the OpenAPI definition to the project.
Navigate to the
/petstore/api_definitionsdirectory. Add the API definition(s) to th
isdirectory. Let's use the Petstore sample open API definition.
If you open the Open API Specification (OAS) document of the Petstore API using a text editor, you will notice the resource (path) definitions of the API following the standard Open API Specification. You will also see the target server (back-end) URL of the API under the "x-wso2-production-endpoints" OAS vendor extension. WSO2 Microgateway uses this interface definition and the target server URL to generate a gateway proxy for the Petstore API.
Use your command line tool to navigate to where the project directory ("petstore") was created and execute the following command to build the project
An executable file (
/petstore/target/petstore.balx) is created to expose the API via WSO2 API Microgateway.
Step 2 - Run the API Microgateway
The executable file (
.balx ), which includes the API artifacts of the project, is used as input to the WSO2 API Microgateway runtime component for the purpose of exposing the APIs. Follow the steps below to expose the APIs via WSO2 API Microgateway.
Execute the following command to start WSO2 API Microgateway.
When WSO2 Microgateway starts successfully, the following log is printed on the console.