Include Fragments In Raml
In last tutorial we demonstrate how to create the fragments in RAML.In this tutorial we will demonstrate how can we include fragments in raml api specification and accelerate the project delivery
Create new API specification
Provide the name
Next step to add the fragments
Click on the 2nd sign(Exchange Dependencies) at left
Click on add dependency using + sign
Select the fragments created in last tutorial
You can see fragments are added as exchange_modules and you can use any fragment in RAML
To use the fragments in RAML you have to include the exact path(copy the path) of that fragment you want to use as shown below
Designer will also show the suggestion if we click our cursor to !include
Sample Raml
#%RAML 1.0 baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/0f82414f-f9b9-4506-a6b3-c064cf0cd645/ # title: CustomerDetails.raml securitySchemes: basicauth: !include /exchange_modules/80516431-2af7-4757-a1f1-995eb48c3a5a/common-fragments/1.0.1/SecurityScheme/basicAuth.raml types: customerdetail: !include dataType/customerdetails.raml genericerror: !include /exchange_modules/80516431-2af7-4757-a1f1-995eb48c3a5a/common-fragments/1.0.1/DataType/genericError.raml traits: header: !include /exchange_modules/80516431-2af7-4757-a1f1-995eb48c3a5a/common-fragments/1.0.1/Traits/commonHeaders.raml /customers: get: description: This API is to retrieved the all customers is: - header: securedBy: [basicauth] responses: 200: body: application/json: type: customerdetail 500: body: application/json: type: genericerror