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 below RAML.

  1. #%RAML 1.0  
  2. baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/d69cd01b-2827-42cc-8e1e-ec2a93c6970c/ #   
  3. title: flights  
  4. /flights:  
  5.  get:  
  6.   queryParameters:  
  7.     destination:  
  8.      required: false  
  9.      enum:  
  10.       - SFO  
  11.       - LAX  
  12.       - CLE  
  13.   responses:  
  14.     200:  
  15.       body:  
  16.         application/json:  
  17.          example:   
  18.           [{"ID":1,  
  19.          "code":"ER38sd",  
  20.          "price":400,  
  21.          "departureDate":"2016/03/20",  
  22.          "origin":"MUA",  
  23.          "destination":"SFO",  
  24.          "emptySetats":0,   
  25.          "plane": {"type":"Boeing 737""totalSeats": 150}},  
  26.          {"ID":2,  
  27.          "code":"ER45if",  
  28.          "price":345.99,  
  29.          "departureDate":"2016/02/11",  
  30.          "origin":"MUA",  
  31.          "destination":"LAX",  
  32.          "emptySeats": 52,  
  33.          "plane":{"type":"Boeing 777""totalSeats": 300}  
  34.          }]  
  35.   
  36.  post:  
  37.   displayName: Add the flight  
  38.   body:  
  39.     application/json:  
  40.      example:  
  41.        {"ID":1,  
  42.          "code":"ER38sd",  
  43.          "price":400,  
  44.          "departureDate":"2016/03/20",  
  45.          "origin":"MUA",  
  46.          "destination":"SFO",  
  47.          "emptySetats":0,   
  48.          "plane": {"type":"Boeing 737""totalSeats": 150}}  
  49.   responses:  
  50.     201:  
  51.       body:  
  52.         application/json:  
  53.          example:  
  54.            {"Message":"Flights added {but not really)"}  
  55.   
  56.  /{ID}:  
  57.   get:  
  58.    responses:  
  59.      200:  
  60.        body:  
  61.          application/json:  
  62.           example:  
  63.             {"ID":1,  
  64.            "code":"ER38sd",  
  65.            "price":400,  
  66.            "departureDate":"2016/03/20",  
  67.            "origin":"MUA",  
  68.            "destination":"SFO",  
  69.            "emptySetats":0,   
  70.            "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.






No comments:

Post a Comment