How to add Drop-Down in Custom Mulesoft Connector using XML SDK πŸ±β€πŸ’»

Upendra Venkata Muralidhar Thunuguntla
2 min readApr 11, 2023

--

What are Anypoint Connectors

Different Datatypes supported in XML SDK

Mulesoft offers 2 SDKs [Java, XML] and in this article, we will have a look at how to add a drop-down in Custom Mulesoft Connector using XML SDK.

First, we need to understand what are the supported data types in XML SDK. Below is the list of Datatypes that are supported:

string, boolean, number, date, datetime, localdatetime, time, localtime, timezone, binary, any, regex and any other Data Type defined in the catalog.

Adding Drop-Down

We need to create a catalog of data types that will be injected into the module.

Let us take an example as follows. We need to replicate the following dropdown in our connector.

1️⃣ Create A JSON Schema

Create a JSON Schema with the type as string and default value and enum configuration. This will be placed under \src\main\resources\ folder with a proper name (eg: levels-schema.json).

{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "string",
"default": "INFO",
"enum": ["DEBUG","ERROR","INFO","TRACE","WARN"]
}

Total 5 values will be coming under dropdown and will have Info as a default selection.

2️⃣ Refer and Add the Schema to Catalogs

Add the JSON schema to the catalog entries as follows. You can add multiple schemas of Types XML and JSON.

<?xml version="1.0" encoding="UTF-8"?>
<catalogs xmlns="http://www.mulesoft.org/schema/mule/types">
<catalog name="levels" format="application/json">
<schema format="application/json+schema" location="./levels-schema.json" />
</catalog>
</catalogs>

3️⃣ Using the Catalog in the Connector

This catalog can be used by both Property & Parameter.

πŸš€ For Property:

<property name="levels" type="levels" displayName="Levels" doc:description="Drop Down for Levels" order="1" />

we need to provide value for type as the name defined in the catalog i.e., levels .

πŸš€ For Parameter:

Under any operation define a new parameter as follows and add the required details.

<operation name="logger" doc:description="Custom logger">
<parameters>
.
.
<parameter name="levels" type="levels" displayName="Levels" defaultValue="INFO" order="1"/>
.
</parameters>
<body>....</body>
</operation>

Now, under the logger operation, you can see a Dropdown with Label Levels that give you the option to Choose from the list of options with a default value.

--

--

Upendra Venkata Muralidhar Thunuguntla
Upendra Venkata Muralidhar Thunuguntla

Written by Upendra Venkata Muralidhar Thunuguntla

πŸ‘¨β€πŸ’» Creating Solutions πŸš€ Bridging the Gap Between Technology and Imagination πŸ’‘ using π™Όπšžπš•πšŽπš‚πš˜πšπš | π™ΉπšŠπšŸπšŠ | π™Ώπš’πšπš‘πš˜πš— | πš‚πšŠπš•πšŽπšœπšπš˜πš›πšŒπšŽ

No responses yet