DigitalBuzz Logo
MuleSoft

Passing at least one mandatory Query Params out of many defined in RAML

Abhishek Bathwal
Posted By
Abhishek Bathwal
Technical Guide
5 min read
Passing at least one mandatory Query Params out of many defined in RAML

The Blog will help in understanding the functionality of queryString in RAML. It helps, passing at least one mandatory query parameter out of more than one mandatory query parameter defined in RAML.

RAML:

RAML 1.0 Specification with queryString type union
Figure 1: RAML definition using queryString with type union (planId | tariff)

RAML Summary:

PlanId

Data type defined for PlanId query parameter.

PlanId dataType definition in RAML
Figure 2: PlanId type specification

Tariff

Data type defined for Amount query parameter.

Tariff dataType definition in RAML
Figure 3: Tariff type specification

Both the query parameters PlanId and Amount unders the dataTypes planId and tariff are defined in RAML and both are required.

Testing:

1. Passing Both the Query Parameters

Testing passing both PlanId and Amount query parameters
Figure 4: Passing both parameters succeeds with 200 OK

2. Passing Only PlanId as Query Parameter

Testing passing only PlanId as query parameter
Figure 5: Passing only PlanId satisfies condition and returns 200 OK

3. Passing Only Amount as Query Parameter

Testing passing only Amount as query parameter
Figure 6: Passing only Amount satisfies condition and returns 200 OK

4. No Query Parameters passed

Testing with no query parameters returns 400 Bad Request
Figure 7: Omitting all parameters triggers validation error (400 Bad Request)
Quote

“Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.”

Abhishek Bathwal
About the Author

Abhishek Bathwal

Integration and API Specialist at DigitalBuzz Software, specializing in RAML API specifications, API governance, and advanced DataWeave architecture.

Share this article