Posted on Leave a comment

Define Responses in RAML

We will get responses from api or external service . there are two type of responses , we will get .

positive response ->success case

Negative response ->failure case

we have to mention all responses in Raml file.

 

Step1:-

Create a specific folder for “Response”

Step2:-

Create files like 200.json,401.json,400.json,500.json

Step3:-

We will refer these file into rootfile(main file) and will use “!include” keyword.

Step4:-

validate your responses

 

Posted on Leave a comment

USAGE OF LIBRARY FRAGMENT

We will explain the usage of library fragment in raml. Library is one of the Raml Fragments. Main advantage of the raml Library is that is can defined multiple types and that can be referred from RAML file.

Step1:-

Log in to Anypoint platform

Step2:-

Click on design center and click on Create Fragments

Step3:-

Provide the name for new fragment

Step4:-

Update the RAML with below information

Define the Individual DataType which is included as part of library

Notepoint:-

Once you create the Library as a fragment you can publish it on exchange to make it reusable across organization, else you can also use this inside individual raml specification in that case you can first create a RAML specification and add the file as a library .

 

Step5:-

we use  uses: “ to include the library and also refer this from exchange, in case of library it is not required to use “!include” to include the library.

 

 

 

Posted on Leave a comment

GENERATE FLOWS FROM RAML

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”

Step1:-

Create a sample RAML in design center

Step2:-

Created the endpoint “/search/{id}”  with get method and here id is uriparams and queryParameters is defined in Raml .

Step3:-

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

and

Step4:-

Create a sample project in anypoint studio

Step5:-

after creating project.

Step6:-

Right Click on project and click on manage dependency-> Click on Manage API

Step7:-

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

Step8:-

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

Search sampleAPI and click on Finish

Step9:-

A new window will open with API name and version -> Click on Apply

after that ,When we click on apply it will ask for scaffold the API, click on Yes

 

Step10:-

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 sampleapi.xml file generated

Step11:-

Project deployed successfully

Posted on Leave a comment

IMPORT FRAGMENTS IN RAML

In this tutorial, we will demonstrate how can we include fragments in raml api specification.

Step1:-

In “API SPECIFICATION“, Define how to api will behave and how it communicates with other system & APIs.

Create new API specification

Step2:-

Provide the name of New Api Specifiation

 

Step3:-

Basic structure is ready like shown below

Step4:-

Click on add dependency using + sign

Step5:-

Select the fragments created in last tutorial

 

Step6:-

You can see fragments are added as exchange_modules and you can use any fragment in RAML

Posted on Leave a comment

CREATE FRAGMENTS IN RAML 1.0

In this tutorial ,we will demonstrate how can we Create Fragments In RAML 1.0.

API fragments”  are reusable component of raml to make the design and build of a reusable API even easier and reduces the effort of implementing APIs.

In tutorials,we will show, how to create the RAML fragments

Step1:-

Log in to Anypoint platform

Step2:-

Create Fragment

Step3:-

provide fragments name and select specification

Step4:-

Create commontraits Trait as Fragment

Step5:-

Publish the created fragments on Exchange so that it can be reusable across all the API’s across organization

Click publish button on top right corner

Fragments published to exchange can be reused in RAML.

I will demonstrate how can we reuse fragments in RAML in next tutorial.