From c69b72e1999578cba15e34677ebd366482cba734 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 9 Dec 2021 23:58:30 +0900 Subject: fix lint --- packages/backend/src/server/api/openapi/errors.ts | 38 ++++---- .../backend/src/server/api/openapi/gen-spec.ts | 104 ++++++++++----------- packages/backend/src/server/api/openapi/schemas.ts | 6 +- 3 files changed, 74 insertions(+), 74 deletions(-) (limited to 'packages/backend/src/server/api/openapi') diff --git a/packages/backend/src/server/api/openapi/errors.ts b/packages/backend/src/server/api/openapi/errors.ts index 43bcc323ba..d7f791c6da 100644 --- a/packages/backend/src/server/api/openapi/errors.ts +++ b/packages/backend/src/server/api/openapi/errors.ts @@ -7,9 +7,9 @@ export const errors = { message: 'Invalid param.', code: 'INVALID_PARAM', id: '3d81ceae-475f-4600-b2a8-2bc116157532', - } - } - } + }, + }, + }, }, '401': { 'CREDENTIAL_REQUIRED': { @@ -18,9 +18,9 @@ export const errors = { message: 'Credential required.', code: 'CREDENTIAL_REQUIRED', id: '1384574d-a912-4b81-8601-c7b1c4085df1', - } - } - } + }, + }, + }, }, '403': { 'AUTHENTICATION_FAILED': { @@ -29,9 +29,9 @@ export const errors = { message: 'Authentication failed. Please ensure your token is correct.', code: 'AUTHENTICATION_FAILED', id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14', - } - } - } + }, + }, + }, }, '418': { 'I_AM_AI': { @@ -40,9 +40,9 @@ export const errors = { message: 'You sent a request to Ai-chan, Misskey\'s showgirl, instead of the server.', code: 'I_AM_AI', id: '60c46cd1-f23a-46b1-bebe-5d2b73951a84', - } - } - } + }, + }, + }, }, '429': { 'RATE_LIMIT_EXCEEDED': { @@ -51,9 +51,9 @@ export const errors = { message: 'Rate limit exceeded. Please try again later.', code: 'RATE_LIMIT_EXCEEDED', id: 'd5826d14-3982-4d2e-8011-b9e9f02499ef', - } - } - } + }, + }, + }, }, '500': { 'INTERNAL_ERROR': { @@ -62,8 +62,8 @@ export const errors = { message: 'Internal error occurred. Please contact us if the error persists.', code: 'INTERNAL_ERROR', id: '5d37dbcb-891e-41ca-a3d6-e690c97775ac', - } - } - } - } + }, + }, + }, + }, }; diff --git a/packages/backend/src/server/api/openapi/gen-spec.ts b/packages/backend/src/server/api/openapi/gen-spec.ts index 48b819727f..1c521f212f 100644 --- a/packages/backend/src/server/api/openapi/gen-spec.ts +++ b/packages/backend/src/server/api/openapi/gen-spec.ts @@ -11,16 +11,16 @@ export function genOpenapiSpec(lang = 'ja-JP') { info: { version: 'v1', title: 'Misskey API', - 'x-logo': { url: '/static-assets/api-doc.png' } + 'x-logo': { url: '/static-assets/api-doc.png' }, }, externalDocs: { description: 'Repository', - url: 'https://github.com/misskey-dev/misskey' + url: 'https://github.com/misskey-dev/misskey', }, servers: [{ - url: config.apiUrl + url: config.apiUrl, }], paths: {} as any, @@ -32,10 +32,10 @@ export function genOpenapiSpec(lang = 'ja-JP') { ApiKeyAuth: { type: 'apiKey', in: 'body', - name: 'i' - } - } - } + name: 'i', + }, + }, + }, }; function genProps(props: { [key: string]: Context; }) { @@ -69,11 +69,11 @@ export function genOpenapiSpec(lang = 'ja-JP') { } : {}), ...(param.name === 'Object' ? { ...(required.length > 0 ? { required } : {}), - properties: (param as any).props ? genProps((param as any).props) : {} + properties: (param as any).props ? genProps((param as any).props) : {}, } : {}), ...(param.name === 'Array' ? { - items: (param as any).ctx ? genProp((param as any).ctx) : {} - } : {}) + items: (param as any).ctx ? genProp((param as any).ctx) : {}, + } : {}), }; } @@ -85,8 +85,8 @@ export function genOpenapiSpec(lang = 'ja-JP') { for (const e of Object.values(endpoint.meta.errors)) { errors[e.code] = { value: { - error: e - } + error: e, + }, }; } } @@ -118,15 +118,15 @@ export function genOpenapiSpec(lang = 'ja-JP') { description: desc, externalDocs: { description: 'Source code', - url: `https://github.com/misskey-dev/misskey/blob/develop/src/server/api/endpoints/${endpoint.name}.ts` + url: `https://github.com/misskey-dev/misskey/blob/develop/src/server/api/endpoints/${endpoint.name}.ts`, }, ...(endpoint.meta.tags ? { - tags: [endpoint.meta.tags[0]] + tags: [endpoint.meta.tags[0]], } : {}), ...(endpoint.meta.requireCredential ? { security: [{ - ApiKeyAuth: [] - }] + ApiKeyAuth: [], + }], } : {}), requestBody: { required: true, @@ -135,10 +135,10 @@ export function genOpenapiSpec(lang = 'ja-JP') { schema: { type: 'object', ...(required.length > 0 ? { required } : {}), - properties: endpoint.meta.params ? genProps(porops) : {} - } - } - } + properties: endpoint.meta.params ? genProps(porops) : {}, + }, + }, + }, }, responses: { ...(endpoint.meta.res ? { @@ -146,58 +146,58 @@ export function genOpenapiSpec(lang = 'ja-JP') { description: 'OK (with results)', content: { 'application/json': { - schema: resSchema - } - } - } + schema: resSchema, + }, + }, + }, } : { '204': { description: 'OK (without any results)', - } + }, }), '400': { description: 'Client error', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error', }, - examples: { ...errors, ...basicErrors['400'] } - } - } + examples: { ...errors, ...basicErrors['400'] }, + }, + }, }, '401': { description: 'Authentication error', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error', }, - examples: basicErrors['401'] - } - } + examples: basicErrors['401'], + }, + }, }, '403': { description: 'Forbidden error', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error', }, - examples: basicErrors['403'] - } - } + examples: basicErrors['403'], + }, + }, }, '418': { description: 'I\'m Ai', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error', }, - examples: basicErrors['418'] - } - } + examples: basicErrors['418'], + }, + }, }, ...(endpoint.meta.limit ? { '429': { @@ -205,29 +205,29 @@ export function genOpenapiSpec(lang = 'ja-JP') { content: { 'application/json': { schema: { - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error', }, - examples: basicErrors['429'] - } - } - } + examples: basicErrors['429'], + }, + }, + }, } : {}), '500': { description: 'Internal server error', content: { 'application/json': { schema: { - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/Error', }, - examples: basicErrors['500'] - } - } + examples: basicErrors['500'], + }, + }, }, - } + }, }; spec.paths['/' + endpoint.name] = { - post: info + post: info, }; } diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index 12fc207c47..723b3e884a 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -42,12 +42,12 @@ export const schemas = { type: 'string', format: 'uuid', description: 'An error ID. This ID is static.', - } + }, }, - required: ['code', 'id', 'message'] + required: ['code', 'id', 'message'], }, }, - required: ['error'] + required: ['error'], }, ...Object.fromEntries( -- cgit v1.2.3-freya