mirror of
https://github.com/hotomoe/hotomoe
synced 2024-11-30 07:48:13 +09:00
良い感じに
This commit is contained in:
parent
1744316656
commit
3a02a7dad8
@ -14,17 +14,19 @@ block main
|
||||
| /
|
||||
span.path= url.path
|
||||
|
||||
p#desc= desc[lang] || desc['ja']
|
||||
if desc
|
||||
p#desc= desc[lang] || desc['ja']
|
||||
|
||||
section
|
||||
h2= i18n('docs.api.endpoints.params')
|
||||
+propTable(params)
|
||||
if params
|
||||
section
|
||||
h2= i18n('docs.api.endpoints.params')
|
||||
+propTable(params)
|
||||
|
||||
if paramDefs
|
||||
each paramDef in paramDefs
|
||||
section(id= paramDef.name)
|
||||
h3= paramDef.name
|
||||
+propTable(paramDef.params)
|
||||
if paramDefs
|
||||
each paramDef in paramDefs
|
||||
section(id= paramDef.name)
|
||||
h3= paramDef.name
|
||||
+propTable(paramDef.params)
|
||||
|
||||
if res
|
||||
section
|
||||
|
@ -25,7 +25,7 @@ html(lang= lang)
|
||||
li Endpoints
|
||||
ul
|
||||
each endpoint in endpoints
|
||||
li: a(href=`/docs/${lang}/api/endpoints/${kebab(endpoint)}`)= endpoint
|
||||
li: a(href=`/docs/${lang}/api/endpoints/${kebab(endpoint.name)}`)= endpoint.name
|
||||
main
|
||||
article
|
||||
block main
|
||||
|
@ -60,6 +60,10 @@ nav
|
||||
background #fff
|
||||
border-right solid 2px #eee
|
||||
|
||||
ul
|
||||
padding 0
|
||||
margin 0
|
||||
|
||||
@media (max-width 1025px)
|
||||
main
|
||||
margin 0
|
||||
|
@ -2,6 +2,12 @@ import * as path from 'path';
|
||||
import * as glob from 'glob';
|
||||
|
||||
export interface IEndpointMeta {
|
||||
desc?: any;
|
||||
|
||||
params?: any;
|
||||
|
||||
res?: any;
|
||||
|
||||
/**
|
||||
* このエンドポイントにリクエストするのにユーザー情報が必須か否か
|
||||
* 省略した場合は false として解釈されます。
|
||||
|
@ -15,6 +15,7 @@ import config from '../../config';
|
||||
import I18n from '../../misc/i18n';
|
||||
import { licenseHtml } from '../../misc/license';
|
||||
const constants = require('../../const.json');
|
||||
import endpoints from '../../server/api/endpoints';
|
||||
|
||||
async function genVars(lang: string): Promise<{ [key: string]: any }> {
|
||||
const vars = {} as { [key: string]: any };
|
||||
@ -23,8 +24,7 @@ async function genVars(lang: string): Promise<{ [key: string]: any }> {
|
||||
|
||||
const cwd = path.resolve(__dirname + '/../../../') + '/';
|
||||
|
||||
const endpoints = glob.sync('built/server/api/endpoints/**/*.js', { cwd });
|
||||
vars['endpoints'] = endpoints.map(ep => require(cwd + ep)).filter(x => x.meta).map(x => x.meta.name);
|
||||
vars['endpoints'] = endpoints;
|
||||
|
||||
const entities = glob.sync('src/docs/api/entities/**/*.yaml', { cwd });
|
||||
vars['entities'] = entities.map(x => {
|
||||
@ -169,7 +169,7 @@ router.get('/assets/*', async ctx => {
|
||||
router.get('/*/api/endpoints/*', async ctx => {
|
||||
const lang = ctx.params[0];
|
||||
const name = ctx.params[1];
|
||||
const ep = require('../../../built/server/api/endpoints/' + name).meta || {};
|
||||
const ep = endpoints.find(e => e.name === name);
|
||||
|
||||
const vars = {
|
||||
title: name,
|
||||
@ -178,11 +178,11 @@ router.get('/*/api/endpoints/*', async ctx => {
|
||||
host: config.api_url,
|
||||
path: name
|
||||
},
|
||||
desc: ep.desc,
|
||||
desc: ep.meta.desc,
|
||||
// @ts-ignore
|
||||
params: sortParams(Object.entries(ep.params).map(([k, v]) => parseParamDefinition(k, v))),
|
||||
paramDefs: extractParamDefRef(Object.entries(ep.params).map(([k, v]) => v)),
|
||||
res: ep.res && ep.res.props ? sortParams(Object.entries(ep.res.props).map(([k, v]) => parsePropDefinition(k, v))) : null,
|
||||
params: ep.meta.params ? sortParams(Object.entries(ep.meta.params).map(([k, v]) => parseParamDefinition(k, v))) : null,
|
||||
paramDefs: ep.meta.params ? extractParamDefRef(Object.entries(ep.meta.params).map(([k, v]) => v)) : null,
|
||||
res: ep.meta.res && ep.meta.res.props ? sortParams(Object.entries(ep.meta.res.props).map(([k, v]) => parsePropDefinition(k, v))) : null,
|
||||
resDefs: null//extractPropDefRef(Object.entries(ep.res.props).map(([k, v]) => parsePropDefinition(k, v)))
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user