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
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 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
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
Getting error —- could not download dependencies.
tq