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) {
|
if (program.cleanList) {
|
||||||
beau.requests.list.forEach(({ VERB, ALIAS, ENDPOINT }) => {
|
beau.requests.list.forEach(({ VERB, ALIAS, ENDPOINT, DOCUMENTATION }) => {
|
||||||
console.log(`${VERB}\t${ALIAS}\t${ENDPOINT}`);
|
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/:
|
GET /posts/:
|
||||||
alias: posts
|
alias: posts
|
||||||
|
documentation:
|
||||||
|
title: Fetch Posts
|
||||||
|
description: Fetches all posts available.
|
||||||
|
|
||||||
POST /posts/:
|
POST /posts/:
|
||||||
alias: new-post
|
alias: new-post
|
||||||
|
documentation:
|
||||||
|
title: New Post
|
||||||
|
|
||||||
GET /users/$posts.body.0.userId:
|
GET /users/$posts.body.0.userId:
|
||||||
alias: post-user
|
alias: post-user
|
||||||
|
documentation:
|
||||||
|
description: Fetches the user for a give post.
|
||||||
params:
|
params:
|
||||||
hello: 'world'
|
hello: 'world'
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class Request {
|
||||||
|
|
||||||
Object.keys(req).forEach(k => config[k.toUpperCase()] = req[k]);
|
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);
|
let { verb, endpoint } = this.parseRequest(REQUEST);
|
||||||
|
|
||||||
this.VERB = verb;
|
this.VERB = verb;
|
||||||
|
|
@ -23,6 +23,8 @@ class Request {
|
||||||
this.ALIAS = ALIAS;
|
this.ALIAS = ALIAS;
|
||||||
this.DEPENDENCIES = this.findDependencies(req);
|
this.DEPENDENCIES = this.findDependencies(req);
|
||||||
|
|
||||||
|
this.DOCUMENTATION = DOCUMENTATION;
|
||||||
|
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue