summaryrefslogtreecommitdiff
path: root/src/server/api/openapi/gen-spec.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2019-04-23 22:35:26 +0900
committerGitHub <noreply@github.com>2019-04-23 22:35:26 +0900
commit0463c6bb0f8fd32740ceb61ccce04c662272a618 (patch)
treea28cbdf6c9cdc14648b8c0e46248665a3ad7e5af /src/server/api/openapi/gen-spec.ts
parentFix #4768 (diff)
downloadsharkey-0463c6bb0f8fd32740ceb61ccce04c662272a618.tar.gz
sharkey-0463c6bb0f8fd32740ceb61ccce04c662272a618.tar.bz2
sharkey-0463c6bb0f8fd32740ceb61ccce04c662272a618.zip
Refactor API (#4770)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update description.ts * wip
Diffstat (limited to 'src/server/api/openapi/gen-spec.ts')
-rw-r--r--src/server/api/openapi/gen-spec.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/server/api/openapi/gen-spec.ts b/src/server/api/openapi/gen-spec.ts
index d194c6c8a8..de26b970ea 100644
--- a/src/server/api/openapi/gen-spec.ts
+++ b/src/server/api/openapi/gen-spec.ts
@@ -2,9 +2,8 @@ import endpoints from '../endpoints';
import { Context } from 'cafy';
import config from '../../../config';
import { errors as basicErrors } from './errors';
-import { schemas } from './schemas';
+import { schemas, convertSchemaToOpenApiSchema } from './schemas';
import { getDescription } from './description';
-import { convertOpenApiSchema } from '../../../misc/schema';
export function genOpenapiSpec(lang = 'ja-JP') {
const spec = {
@@ -59,7 +58,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
deprecated: (param.data || {}).deprecated,
...((param.data || {}).default ? { default: (param.data || {}).default } : {}),
type: param.name === 'ID' ? 'string' : param.name.toLowerCase(),
- ...(param.name === 'ID' ? { example: 'xxxxxxxxxxxxxxxxxxxxxxxx', format: 'id' } : {}),
+ ...(param.name === 'ID' ? { example: 'xxxxxxxxxx', format: 'id' } : {}),
nullable: param.isNullable,
...(param.name === 'String' ? {
...((param as any).enum ? { enum: (param as any).enum } : {}),
@@ -106,7 +105,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
const required = endpoint.meta.params ? Object.entries(endpoint.meta.params).filter(([k, v]) => !v.validator.isOptional).map(([k, v]) => k) : [];
- const resSchema = endpoint.meta.res ? convertOpenApiSchema(endpoint.meta.res) : {};
+ const resSchema = endpoint.meta.res ? convertSchemaToOpenApiSchema(endpoint.meta.res) : {};
let desc = (endpoint.meta.desc ? endpoint.meta.desc[lang] : 'No description provided.') + '\n\n';
desc += `**Credential required**: *${endpoint.meta.requireCredential ? 'Yes' : 'No'}*`;