RAML初识

RAML

raml()
在线的API designer tool

ENTER THE ROOT

确定根的url

1
2
3
4
5
#%RAML 1.0
---
title: e-BookMobile API
baseUri: http://api.e-bookmobile.com/{version}
version: v1

ENTER RESOURCES

确定资源,资源一般都是一个名词

1
2
3
/users:
/authors:
/books:

ENTER METHODS

确定方法

1
2
3
4
/books:
get:
post:
put:

ENTER URI PARAMETERS

确定URI的参数

1
2
3
4
5
6
7
8
9
10
11
12
/books:
get:
put:
post:
/{bookTitle}:
get:
put:
delete:
/author:
get:
/publisher:
get:

确定查询的参数

1
2
3
4
5
6
7
8
9
10
11
/books:
/{bookTitle}
get:
queryParameters:
author:
publicationYear:
rating:
isbn:
put:
queryParameters:
access_token:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/books:
/{bookTitle}
get:
queryParameters:
author:
displayName: Author
type: string
description: An author's full name
example: Mary Roach
required: false
publicationYear:
displayName: Pub Year
type: number
description: The year released for the first time in the US
example: 1984
required: false
rating:
displayName: Rating
type: number
description: Average rating (1-5) submitted by users
example: 3.14
required: false
isbn:
displayName: ISBN
type: string
minLength: 10
example: 0321736079?
put:
queryParameters:
access_token:
displayName: Access Token
type: string
description: Token giving you permission to make call
required: true

ENTER RESPONSES

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/books:
/{bookTitle}:
get:
description: Retrieve a specific book title
responses:
200:
body:
application/json:
example: |
{
"data": {
"id": "SbBGk",
"title": "Stiff: The Curious Lives of Human Cadavers",
"description": null,
"datetime": 1341533193,
"genre": "science",
"author": "Mary Roach",
"link": "http://e-bookmobile.com/books/Stiff",
},
"success": true,
"status": 200
}
坚持技术分享,您的支持将鼓励我继续创作!