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

Include Fragments In Raml

 

Provide the name Include Fragments In Raml

 

Next step to add the fragments

Click on the 2nd sign(Exchange Dependencies) at left

Include Fragments In Raml

 

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     
  
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
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments