How to create a API specification and deploy in Anypoint Platform?

How to create a API specification and deploy in Anypoint Platform?

1. Go to the Design Center.

2. Click API Specification.

3. Enter Project Name, select Start with API designer and click Create button.

4. Use the following RAML.

#%RAML 1.0  
baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/d69cd01b-2827-42cc-8e1e-ec2a93c6970c/ #   
title: flights  
/flights:  
 get:  
  queryParameters:  
	destination:  
	 required: false  
	 enum:  
	  - SFO  
	  - LAX  
	  - CLE  
  responses:  
	200:  
	  body:  
		application/json:  
		 example:   
		  [{"ID":1,  
		 "code":"ER38sd",  
		 "price":400,  
		 "departureDate":"2016/03/20",  
		 "origin":"MUA",  
		 "destination":"SFO",  
		 "emptySetats":0,   
		 "plane": {"type":"Boeing 737", "totalSeats": 150}},  
		 {"ID":2,  
		 "code":"ER45if",  
		 "price":345.99,  
		 "departureDate":"2016/02/11",  
		 "origin":"MUA",  
		 "destination":"LAX",  
		 "emptySeats": 52,  
		 "plane":{"type":"Boeing 777", "totalSeats": 300}  
		 }]  
  
 post:  
  displayName: Add the flight  
  body:  
	application/json:  
	 example:  
	   {"ID":1,  
		 "code":"ER38sd",  
		 "price":400,  
		 "departureDate":"2016/03/20",  
		 "origin":"MUA",  
		 "destination":"SFO",  
		 "emptySetats":0,   
		 "plane": {"type":"Boeing 737", "totalSeats": 150}}  
  responses:  
	201:  
	  body:  
		application/json:  
		 example:  
		   {"Message":"Flights added {but not really)"}  
  
 /{ID}:  
  get:  
   responses:  
	 200:  
	   body:  
		 application/json:  
		  example:  
			{"ID":1,  
		   "code":"ER38sd",  
		   "price":400,  
		   "departureDate":"2016/03/20",  
		   "origin":"MUA",  
		   "destination":"SFO",  
		   "emptySetats":0,   
		   "plane": {"type":"Boeing 737", "totalSeats": 150}}  

5. Select Publish to Exchange.

6. Enter a name and click Publish button.

7. Go to the API Manager.

8. Click “Manage API” and select “Manage API from Exchange”.

9. Save Manage API from Exchange

10. Select the Runtime version. Enter unique Proxy application name. Click Deploy.

11. Get the Proxy URL.

12. Add /console and open it.

Leave a Reply