1. What is API Specification
An API Specification provides an understanding of how an API behaves.
- What kind of request it accepts
- What kind of response it returns
- What are mandatory fields/data types, etc.
2. Design Center of Anypoint Platform
Design Center helps us to create API Specification in RAML(RESTful API Modeling Language).
It supports RAML by versions 0.8 and 1.
Core Elements:
Resource
It is the unique name we give to identify a resourceMethod
GET, POST, PUT, DELETE, PATCH etc.Request
Body, queryparams, uriparams, headers, etc.Http Status
200, 201, 400, 404, 500, etc.
3. Design API
- 3-1) Login into Anypoint Platform, anypoint.mulesoft.com
- 3-2) Create new API specification
RAML Code:
#%RAML 1.0
title: session-2
/search:
get:
queryParameters:
keyword:
type: string
minLength: 3
maxLength: 10
responses:
200:
body:
application/json:
example:
{"message" : "result returned successful"}
- 3-3) Mock API
- 3-4) Make your API Spec public
Note: the copied public URL is the root, you should combined with your relative URL.
(eg: http://xxxx/xxx + /search?keyword=abc, http://xxxx/xxx is root URL you copied, /search?keyword=abc is your relative request URL)