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:
David Diaz 2017-10-21 01:17:15 -06:00
parent baa4a4eafc
commit e8f3d0eda2
3 changed files with 18 additions and 3 deletions

View File

@ -56,8 +56,14 @@ if (
}
if (program.cleanList) {
beau.requests.list.forEach(({ VERB, ALIAS, 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}`);
}
});
}

View File

@ -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'

View File

@ -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;
}