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

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago