fix(misskey-js): `build-misskey-js-with-types`時は`api.json`のGETをスキップするように

This commit is contained in:
zyoshoka 2024-01-13 13:23:31 +09:00
parent c6c668d873
commit 865458989f
No known key found for this signature in database
GPG Key ID: 0C2CB8FBA309A5B8
8 changed files with 16 additions and 1733 deletions

View File

@ -18,7 +18,7 @@
"build-assets": "node ./scripts/build-assets.mjs",
"build": "pnpm build-pre && pnpm -r build && pnpm build-assets",
"build-storybook": "pnpm --filter frontend build-storybook",
"build-misskey-js-with-types": "pnpm --filter backend build && pnpm --filter backend generate-api-json && ncp packages/backend/built/api.json packages/misskey-js/generator/api.json && pnpm --filter misskey-js update-autogen-code && pnpm --filter misskey-js build && pnpm --filter misskey-js api",
"build-misskey-js-with-types": "pnpm --filter backend build && pnpm --filter backend generate-api-json --skip-get && ncp packages/backend/built/api-get-skipped.json packages/misskey-js/generator/api.json && pnpm --filter misskey-js update-autogen-code && pnpm --filter misskey-js build && pnpm --filter misskey-js api",
"start": "pnpm check:connect && cd packages/backend && node ./built/boot/entry.js",
"start:test": "cd packages/backend && cross-env NODE_ENV=test node ./built/boot/entry.js",
"init": "pnpm migrate",

View File

@ -1,8 +1,13 @@
import { loadConfig } from './built/config.js'
import { genOpenapiSpec } from './built/server/api/openapi/gen-spec.js'
import { writeFileSync } from "node:fs";
import { writeFileSync } from 'node:fs';
import { argv } from 'node:process';
const skipGet = argv.includes('--skip-get');
const config = loadConfig();
const spec = genOpenapiSpec(config);
const spec = genOpenapiSpec(config, skipGet);
writeFileSync('./built/api.json', JSON.stringify(spec), 'utf-8');
const path = `./built/api${skipGet ? '-get-skipped' : ''}.json`;
writeFileSync(path, JSON.stringify(spec), 'utf-8');

View File

@ -8,7 +8,7 @@ import endpoints, { IEndpoint } from '../endpoints.js';
import { errors as basicErrors } from './errors.js';
import { schemas, convertSchemaToOpenApiSchema } from './schemas.js';
export function genOpenapiSpec(config: Config) {
export function genOpenapiSpec(config: Config, skipGet = false) {
const spec = {
openapi: '3.1.0',
@ -210,12 +210,7 @@ export function genOpenapiSpec(config: Config) {
};
spec.paths['/' + endpoint.name] = {
...(endpoint.meta.allowGet ? {
get: {
...info,
operationId: 'get/' + endpoint.name,
},
} : {}),
...(!skipGet && endpoint.meta.allowGet ? { get: info } : {}),
post: info,
};
}

View File

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-13T02:47:41.647Z
* generatedAt: 2024-01-13T04:19:51.712Z
*/
import type { SwitchCaseResponseType } from '../api.js';

View File

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-13T02:47:41.642Z
* generatedAt: 2024-01-13T04:19:51.705Z
*/
import type {

View File

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-13T02:47:41.639Z
* generatedAt: 2024-01-13T04:19:51.701Z
*/
import { operations } from './types.js';

View File

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-13T02:47:41.637Z
* generatedAt: 2024-01-13T04:19:51.699Z
*/
import { components } from './types.js';

File diff suppressed because it is too large Load Diff