Generate Flows From RAML Using Manage Dependency

 

In this tutorial 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
baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/ba98d886-7a16-4c6e-9e62-d3a8723dffe2/ # 
title: employee
description: This API is to retrieve employeeid
version: v1
mediaType:  [ application/json ]
protocols:
  - HTTP
/employee:
  get:
    displayName: Retrieve employee
    description: Retrieve employee by empid
    queryParameters:
      empId:
          type: string
          description: "EmpId"
          example: "342343"
          required: true
    responses:
      200:
        description: Success response of employee
        body:
          application/json:

 

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

Generate Flows From RAML Using Manage Dependency

 

Create a sample project in anypoint studio

Generate Flows From RAML Using Manage Dependency

 

Right Click on manage dependency-> Click on Manage API

Generate Flows From RAML Using Manage Dependency

 

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

Generate Flows From RAML Using Manage Dependency

 

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

Search Employee API and click on Finish

Generate Flows From RAML Using Manage Dependency

 

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

Generate Flows From RAML Using Manage Dependency

 

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

Generate Flows From RAML Using Manage Dependency

 

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
baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/ba98d886-7a16-4c6e-9e62-d3a8723dffe2/ # 
title: employee
description: This API is to retrieve employeeid
version: v1
mediaType:  [ application/json ]
protocols:
  - HTTP

/employee:
  get:
    displayName: Retrieve employee
    description: Retrieve employee by empid
    queryParameters:
      empId:
          type: string
          description: "EmpId"
          example: "342343"
          required: true
    responses:
      200:
        description: Success repsonse of employee
        body:
          application/json:

/employeeaddress:
  get:
    displayName: Retrieve address
    description: Retrieve address by addid
    queryParameters:
      empId:
          type: string
          description: "addid"
          example: "efrd"
          required: true
    responses:
      200:
        description: Success repsonse of addid
        body:
          application/json:

 

Publish the API on exchange with new version 1.0.2

 

Go to Anypoint Studio and Right click on project as mentioned above

Click on check for updates as shown below

Generate Flows From RAML Using Manage Dependency

 

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

 

Deploy the project

We can see employee-1.0.2-raml.zip added in anypoint project as a dependency

 

Updated Mule Flow

 

In Pom.xml also raml dependency added

 

Sample Application: generateflowsfromraml sample application

  
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.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Thakur Gaurav Chauhan

Getting error —- could not download dependencies.

alekhya
alekhya
1 year ago

tq