Skip to content

Commit

Permalink
fix(misskey-js): build-misskey-js-with-types時はapi.jsonのGETをスキップするように
Browse files Browse the repository at this point in the history
  • Loading branch information
zyoshoka committed Jan 13, 2024
1 parent c6c668d commit 8654589
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 1,893 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 8 additions & 3 deletions packages/backend/generate_api_json.js
Original file line number Diff line number Diff line change
@@ -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);

const path = `./built/api${skipGet ? '-get-skipped' : ''}.json`;

writeFileSync('./built/api.json', JSON.stringify(spec), 'utf-8');
writeFileSync(path, JSON.stringify(spec), 'utf-8');
9 changes: 2 additions & 7 deletions packages/backend/src/server/api/openapi/gen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -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,
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/src/autogen/apiClientJSDoc.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/src/autogen/endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-13T02:47:41.642Z
* generatedAt: 2024-01-13T04:19:51.705Z
*/

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/src/autogen/entities.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/src/autogen/models.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Loading

0 comments on commit 8654589

Please sign in to comment.