summaryrefslogtreecommitdiff
path: root/src/web/docs/api/endpoints/gulpfile.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-14 22:36:04 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-14 22:36:04 +0900
commit5b6641003139606d54e3b8646b156d4fcd05b9d5 (patch)
tree23458fc8df2dce3ba055540d6bb03fc9f49a7362 /src/web/docs/api/endpoints/gulpfile.ts
parent:pizza: (diff)
downloadsharkey-5b6641003139606d54e3b8646b156d4fcd05b9d5.tar.gz
sharkey-5b6641003139606d54e3b8646b156d4fcd05b9d5.tar.bz2
sharkey-5b6641003139606d54e3b8646b156d4fcd05b9d5.zip
:v:
Diffstat (limited to 'src/web/docs/api/endpoints/gulpfile.ts')
-rw-r--r--src/web/docs/api/endpoints/gulpfile.ts39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/web/docs/api/endpoints/gulpfile.ts b/src/web/docs/api/endpoints/gulpfile.ts
index a2c3944709..e375447c55 100644
--- a/src/web/docs/api/endpoints/gulpfile.ts
+++ b/src/web/docs/api/endpoints/gulpfile.ts
@@ -14,7 +14,8 @@ import config from './../../../../conf';
const parseParam = param => {
const id = param.type.match(/^id\((.+?)\)/);
- const object = param.type.match(/^object\((.+?)\)/);
+ const entity = param.type.match(/^entity\((.+?)\)/);
+ const isObject = /^object/.test(param.type);
const isArray = /\[\]$/.test(param.type);
if (id) {
param.kind = 'id';
@@ -24,18 +25,40 @@ const parseParam = param => {
param.type += '[]';
}
}
- if (object) {
- param.kind = 'object';
+ if (entity) {
+ param.kind = 'entity';
param.type = 'object';
- param.def = object[1];
+ param.entity = entity[1];
if (isArray) {
param.type += '[]';
}
}
+ if (isObject) {
+ param.kind = 'object';
+ }
return param;
};
+const extractDefs = params => {
+ const defs = [];
+
+ params.forEach(param => {
+ if (param.def) {
+ defs.push({
+ name: param.defName,
+ params: param.def.map(p => parseParam(p))
+ });
+
+ const childDefs = extractDefs(param.def);
+
+ defs.concat(childDefs);
+ }
+ });
+
+ return defs;
+};
+
gulp.task('doc:endpoints', () => {
glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => {
if (globErr) {
@@ -50,11 +73,9 @@ gulp.task('doc:endpoints', () => {
url: `${config.api_url}/${ep.endpoint}`,
desc: ep.desc,
params: ep.params.map(p => parseParam(p)),
- paramDefs: Object.keys(ep.paramDefs).map(key => ({
- name: key,
- params: ep.paramDefs[key].map(p => parseParam(p))
- })),
- res: ep.res.map(p => parseParam(p))
+ paramDefs: extractDefs(ep.params),
+ res: ep.res.map(p => parseParam(p)),
+ resDefs: extractDefs(ep.res)
};
pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => {
if (renderErr) {