summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/openapi/gen-spec.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-03-02 17:28:34 +0000
committerdakkar <dakkar@thenautilus.net>2024-03-02 17:28:34 +0000
commit23f476dbf32ef9a2fc7d2ed7aab9ce706a2409d0 (patch)
tree0b9e79c2f18f4a206811561fa255f2510f60c175 /packages/backend/src/server/api/openapi/gen-spec.ts
parentmerge: Add missing IMPORTANT_NOTES.md from Sharkey/OldJoinSharkey (!443) (diff)
parentmerge: put back the readme (!447) (diff)
downloadsharkey-23f476dbf32ef9a2fc7d2ed7aab9ce706a2409d0.tar.gz
sharkey-23f476dbf32ef9a2fc7d2ed7aab9ce706a2409d0.tar.bz2
sharkey-23f476dbf32ef9a2fc7d2ed7aab9ce706a2409d0.zip
Merge branch 'develop' into release/2024.3.1
Diffstat (limited to 'packages/backend/src/server/api/openapi/gen-spec.ts')
-rw-r--r--packages/backend/src/server/api/openapi/gen-spec.ts22
1 files changed, 12 insertions, 10 deletions
diff --git a/packages/backend/src/server/api/openapi/gen-spec.ts b/packages/backend/src/server/api/openapi/gen-spec.ts
index 0e71510b48..b5f91ff542 100644
--- a/packages/backend/src/server/api/openapi/gen-spec.ts
+++ b/packages/backend/src/server/api/openapi/gen-spec.ts
@@ -1,16 +1,16 @@
/*
- * SPDX-FileCopyrightText: syuilo and other misskey contributors
+ * SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Config } from '@/config.js';
import endpoints, { IEndpoint } from '../endpoints.js';
import { errors as basicErrors } from './errors.js';
-import { schemas, convertSchemaToOpenApiSchema } from './schemas.js';
+import { getSchemas, convertSchemaToOpenApiSchema } from './schemas.js';
-export function genOpenapiSpec(config: Config) {
+export function genOpenapiSpec(config: Config, includeSelfRef = false) {
const spec = {
- openapi: '3.0.0',
+ openapi: '3.1.0',
info: {
version: config.version,
@@ -20,7 +20,7 @@ export function genOpenapiSpec(config: Config) {
externalDocs: {
description: 'Repository',
- url: 'https://github.com/misskey-dev/misskey',
+ url: 'https://activitypub.software/TransFem-org/Sharkey',
},
servers: [{
@@ -30,7 +30,7 @@ export function genOpenapiSpec(config: Config) {
paths: {} as any,
components: {
- schemas: schemas,
+ schemas: getSchemas(includeSelfRef),
securitySchemes: {
bearerAuth: {
@@ -56,7 +56,7 @@ export function genOpenapiSpec(config: Config) {
}
}
- const resSchema = endpoint.meta.res ? convertSchemaToOpenApiSchema(endpoint.meta.res) : {};
+ const resSchema = endpoint.meta.res ? convertSchemaToOpenApiSchema(endpoint.meta.res, 'res', includeSelfRef) : {};
let desc = (endpoint.meta.description ? endpoint.meta.description : 'No description provided.') + '\n\n';
@@ -71,7 +71,7 @@ export function genOpenapiSpec(config: Config) {
}
const requestType = endpoint.meta.requireFile ? 'multipart/form-data' : 'application/json';
- const schema = { ...endpoint.params };
+ const schema = { ...convertSchemaToOpenApiSchema(endpoint.params, 'param', false) };
if (endpoint.meta.requireFile) {
schema.properties = {
@@ -98,7 +98,7 @@ export function genOpenapiSpec(config: Config) {
description: desc,
externalDocs: {
description: 'Source code',
- url: `https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/${endpoint.name}.ts`,
+ url: `https://activitypub.software/TransFem-org/Sharkey/-/tree/develop/packages/backend/src/server/api/endpoints/${endpoint.name}.ts`,
},
...(endpoint.meta.tags ? {
tags: [endpoint.meta.tags[0]],
@@ -210,7 +210,9 @@ export function genOpenapiSpec(config: Config) {
};
spec.paths['/' + endpoint.name] = {
- ...(endpoint.meta.allowGet ? { get: info } : {}),
+ ...(endpoint.meta.allowGet ? {
+ get: info,
+ } : {}),
post: info,
};
}