Connect to anything with MI’s new Connector Generator

In the new integration space, calling APIs is key. If you are a developer, you know how hard it is to look at an API spec/documentation and write an integration.
With the new 4.4.0 update of MI, we built something cool — a Connector Generator for OpenAPI Specs. Now, you no longer need to look at those boring docs/specs when dealing with API calls.
For example, if you are writing a B2B integration with a vendor API, you can simply import their OpenAPI Spec into MI, generate a connector, and use it to communicate with the API.
Here’s an overview of what we’re going to do, We will connect to the PetStore API (https://petstore.swagger.io) using WSO2 MI. How will we do that? Yes… By using a generated connector!

First, We need their Open API Spec, which is available in https://petstore3.swagger.io/ .
Create/Open a project in MI and create/open an API.

Click the “+” Button where we all use to add mediators.

Go to the “Connections” tab and click on “Add new connection”.

Then click “Import Connector”.

Then you just need to give the open API spec file, in this case Swagger PetStore OAS.

Thats it, you connector is generated :)
Now if you go to the mediator tab, you will see the generated connector and all it’s operations.

Yep. Thats it. Thats how you generate a connector for an any OAS.
Lets try a one operation, Click on “GetPetById” operation, and create “Connection”.

Then fill out the getPetById operation, use 1 as pet_id and tick the “Replace Message Body” so the result will add to the message context.

Then add a “Respond” mediator;

Then run it by clicking RUN button and “Try it out” the api by executing it;

Ta-da! Here’s the result.

So, that’s it! This is MI’s new Custom Connector Generator. This tool works with most OpenAPI Specs, but it may not support large or complex ones. If you find something not working as expected, you can contribute to improving it by submitting a PR to: https://github.com/wso2-extensions/esb-connector-tooling .
Thanks for reading! :) Have a great day! :)