coderz.py

Keep Coding Keep Cheering!

Generate Flows From RAML Using Manage Dependency

Mulesoft

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

Leave a Comment

Your email address will not be published. Required fields are marked *

Advertisement