Categories: Mule 4MulesoftRAML

Generate Flows From RAML Using Manage Dependency

This Blog is to give an idea of how we can implement API specifications and also we will Generate Flows From RAML Using Manage Dependency, This is one of the easiest way to generate the flow from RAML, in that case raml will be referred from Anypoint Exchange directly and a dependency will be added in POM.xml

Create a sample RAML in design center
#%RAML 1.0
title: generateFlowUsingManageDependency
version: v1
protocols: [ HTTP ]
mediaType: application/json

/employee:
  get:
    displayName: Retrieve employee
    description: Retrive employee by empid
    queryParameters:
      empId:
        type: string
        description: "112203"
        example: "rqstvl"
        required: true
    responses:
      200:
        description: success response of employee
        body:
          application/json:
            example:
              "employees details fetched"

      400:
        description: "bad request of employee"
        body:
          application/json:
            example:
              "bad request"  

Publish the API on Exchange, see below Employee API is published on exchange with version 1.0.0

Create a sample project in anypoint studio

Right Click on manage dependency-> Click on Manage API

New Window Open-> Click on + Sign and click on From Exchange

A new search window will open to search modules/api from exchange

Search Employee API and click on Finish

A new window will open with API name and version -> Click on Apply

When we click on apply it will ask for scaffold the API, click on Yes

It will give the success message, click on Apply and Close

We can see the scaffolding complete successfully and flows are generated as shown below and employee.xml file generated

Project deployed successfully

In next step we will add one more resource in RAML and try to publish the same on exchange with new version and see how can we regenerate the flows using manage dependency

We have added one more resource as employeeaddress

#%RAML 1.0
title: generateFlowUsingManageDependency
version: v1
protocols: [ HTTP ]
mediaType: application/json

/employee:
  get:
    displayName: Retrieve employee
    description: Retrive employee by empid
    queryParameters:
      empId:
        type: string
        description: "112203"
        example: "rqstvl"
        required: true
    responses:
      200:
        description: success response of employee
        body:
          application/json:
            example:
              "employees details fetched"

      400:
        description: "bad request of employee"
        body:
          application/json:
            example:
              "bad request"  
/employeeaddress:
  get:
    displayName: Retrieve address
    description: Retrive address by addid      
    queryParameters:
      empId:
        type: string
        description: "112203"
        example: "rqstvl"
        required: true        
    responses:
      200:
        description: success response of addid
        body:
          application/json:
            example:
              "data fetched for employees"

      400:
        description: "bad request of addid"
        body:
          application/json:
            example:
              "bad request"    

Publish the API on exchange with new version 1.0.2

click on update all dependencies and click on Update Version and Apply

Again scaffolding will happen and completed successfully and one more flow generated for employeeaddress

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

Instagram

Facebook

Recent Posts

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

2 days ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

3 weeks ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

3 weeks ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or…

4 weeks ago

Autocomplete System Implementation

Build an autocomplete system that, given a query string s and a set of possible…

4 weeks ago

Job Scheduler Implementation

Design a job scheduler that accepts a function f and an integer n. The scheduler…

4 weeks ago