mirror of https://github.com/Seich/Beau.git
Added support for a documentation field in the beau.yaml file.
This field will be use to prettify the output of certain tools and to document apis.
This commit is contained in:
parent
baa4a4eafc
commit
e8f3d0eda2
10
bin/beau
10
bin/beau
|
|
@ -56,8 +56,14 @@ if (
|
|||
}
|
||||
|
||||
if (program.cleanList) {
|
||||
beau.requests.list.forEach(({ VERB, ALIAS, ENDPOINT }) => {
|
||||
console.log(`${VERB}\t${ALIAS}\t${ENDPOINT}`);
|
||||
beau.requests.list.forEach(({ VERB, ALIAS, ENDPOINT, DOCUMENTATION }) => {
|
||||
if (typeof DOCUMENTATION !== 'undefined') {
|
||||
let {title, description} = DOCUMENTATION;
|
||||
console.log(`${VERB}\t${ALIAS}\t${ENDPOINT}\t${title}\t${description}`);
|
||||
|
||||
} else {
|
||||
console.log(`${VERB}\t${ALIAS}\t${ENDPOINT}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,18 @@ host: 'http://jsonplaceholder.typicode.com'
|
|||
|
||||
GET /posts/:
|
||||
alias: posts
|
||||
documentation:
|
||||
title: Fetch Posts
|
||||
description: Fetches all posts available.
|
||||
|
||||
POST /posts/:
|
||||
alias: new-post
|
||||
documentation:
|
||||
title: New Post
|
||||
|
||||
GET /users/$posts.body.0.userId:
|
||||
alias: post-user
|
||||
documentation:
|
||||
description: Fetches the user for a give post.
|
||||
params:
|
||||
hello: 'world'
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Request {
|
|||
|
||||
Object.keys(req).forEach(k => config[k.toUpperCase()] = req[k]);
|
||||
|
||||
let { REQUEST, ALIAS, PAYLOAD, HOST, PARAMS, HEADERS } = config;
|
||||
let { REQUEST, ALIAS, PAYLOAD, HOST, PARAMS, HEADERS, DOCUMENTATION } = config;
|
||||
let { verb, endpoint } = this.parseRequest(REQUEST);
|
||||
|
||||
this.VERB = verb;
|
||||
|
|
@ -23,6 +23,8 @@ class Request {
|
|||
this.ALIAS = ALIAS;
|
||||
this.DEPENDENCIES = this.findDependencies(req);
|
||||
|
||||
this.DOCUMENTATION = DOCUMENTATION;
|
||||
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue