mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-10-31 15:21:46 +09:00
fix(misskey-js): 自動生成物の冒頭からバージョンと日付を削除 (#13185)
This commit is contained in:
parent
500ea793b3
commit
c81b61eb2e
@ -4,22 +4,6 @@ import { toPascal } from 'ts-case-convert';
|
|||||||
import OpenAPIParser from '@readme/openapi-parser';
|
import OpenAPIParser from '@readme/openapi-parser';
|
||||||
import openapiTS from 'openapi-typescript';
|
import openapiTS from 'openapi-typescript';
|
||||||
|
|
||||||
function generateVersionHeaderComment(openApiDocs: OpenAPIV3_1.Document): string {
|
|
||||||
const contents = {
|
|
||||||
version: openApiDocs.info.version,
|
|
||||||
generatedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
const lines: string[] = [];
|
|
||||||
lines.push('/*');
|
|
||||||
for (const [key, value] of Object.entries(contents)) {
|
|
||||||
lines.push(` * ${key}: ${value}`);
|
|
||||||
}
|
|
||||||
lines.push(' */');
|
|
||||||
|
|
||||||
return lines.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function generateBaseTypes(
|
async function generateBaseTypes(
|
||||||
openApiDocs: OpenAPIV3_1.Document,
|
openApiDocs: OpenAPIV3_1.Document,
|
||||||
openApiJsonPath: string,
|
openApiJsonPath: string,
|
||||||
@ -36,9 +20,6 @@ async function generateBaseTypes(
|
|||||||
}
|
}
|
||||||
lines.push('');
|
lines.push('');
|
||||||
|
|
||||||
lines.push(generateVersionHeaderComment(openApiDocs));
|
|
||||||
lines.push('');
|
|
||||||
|
|
||||||
const generatedTypes = await openapiTS(openApiJsonPath, { exportType: true });
|
const generatedTypes = await openapiTS(openApiJsonPath, { exportType: true });
|
||||||
lines.push(generatedTypes);
|
lines.push(generatedTypes);
|
||||||
lines.push('');
|
lines.push('');
|
||||||
@ -59,8 +40,6 @@ async function generateSchemaEntities(
|
|||||||
const schemaNames = Object.keys(schemas);
|
const schemaNames = Object.keys(schemas);
|
||||||
const typeAliasLines: string[] = [];
|
const typeAliasLines: string[] = [];
|
||||||
|
|
||||||
typeAliasLines.push(generateVersionHeaderComment(openApiDocs));
|
|
||||||
typeAliasLines.push('');
|
|
||||||
typeAliasLines.push(`import { components } from '${toImportPath(typeFileName)}';`);
|
typeAliasLines.push(`import { components } from '${toImportPath(typeFileName)}';`);
|
||||||
typeAliasLines.push(
|
typeAliasLines.push(
|
||||||
...schemaNames.map(it => `export type ${it} = components['schemas']['${it}'];`),
|
...schemaNames.map(it => `export type ${it} = components['schemas']['${it}'];`),
|
||||||
@ -119,9 +98,6 @@ async function generateEndpoints(
|
|||||||
|
|
||||||
const entitiesOutputLine: string[] = [];
|
const entitiesOutputLine: string[] = [];
|
||||||
|
|
||||||
entitiesOutputLine.push(generateVersionHeaderComment(openApiDocs));
|
|
||||||
entitiesOutputLine.push('');
|
|
||||||
|
|
||||||
entitiesOutputLine.push(`import { operations } from '${toImportPath(typeFileName)}';`);
|
entitiesOutputLine.push(`import { operations } from '${toImportPath(typeFileName)}';`);
|
||||||
entitiesOutputLine.push('');
|
entitiesOutputLine.push('');
|
||||||
|
|
||||||
@ -139,9 +115,6 @@ async function generateEndpoints(
|
|||||||
|
|
||||||
const endpointOutputLine: string[] = [];
|
const endpointOutputLine: string[] = [];
|
||||||
|
|
||||||
endpointOutputLine.push(generateVersionHeaderComment(openApiDocs));
|
|
||||||
endpointOutputLine.push('');
|
|
||||||
|
|
||||||
endpointOutputLine.push('import type {');
|
endpointOutputLine.push('import type {');
|
||||||
endpointOutputLine.push(
|
endpointOutputLine.push(
|
||||||
...[emptyRequest, emptyResponse, ...entities].map(it => '\t' + it.generateName() + ','),
|
...[emptyRequest, emptyResponse, ...entities].map(it => '\t' + it.generateName() + ','),
|
||||||
@ -187,9 +160,6 @@ async function generateApiClientJSDoc(
|
|||||||
|
|
||||||
const endpointOutputLine: string[] = [];
|
const endpointOutputLine: string[] = [];
|
||||||
|
|
||||||
endpointOutputLine.push(generateVersionHeaderComment(openApiDocs));
|
|
||||||
endpointOutputLine.push('');
|
|
||||||
|
|
||||||
endpointOutputLine.push(`import type { SwitchCaseResponseType } from '${toImportPath(apiClientFileName)}';`);
|
endpointOutputLine.push(`import type { SwitchCaseResponseType } from '${toImportPath(apiClientFileName)}';`);
|
||||||
endpointOutputLine.push(`import type { Endpoints } from '${toImportPath(endpointsFileName)}';`);
|
endpointOutputLine.push(`import type { Endpoints } from '${toImportPath(endpointsFileName)}';`);
|
||||||
endpointOutputLine.push('');
|
endpointOutputLine.push('');
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
/*
|
|
||||||
* version: 2024.2.0-beta.8
|
|
||||||
* generatedAt: 2024-02-04T16:51:09.469Z
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { SwitchCaseResponseType } from '../api.js';
|
import type { SwitchCaseResponseType } from '../api.js';
|
||||||
import type { Endpoints } from './endpoint.js';
|
import type { Endpoints } from './endpoint.js';
|
||||||
|
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
/*
|
|
||||||
* version: 2024.2.0-beta.8
|
|
||||||
* generatedAt: 2024-02-04T16:51:09.467Z
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
EmptyRequest,
|
EmptyRequest,
|
||||||
EmptyResponse,
|
EmptyResponse,
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
/*
|
|
||||||
* version: 2024.2.0-beta.8
|
|
||||||
* generatedAt: 2024-02-04T16:51:09.466Z
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { operations } from './types.js';
|
import { operations } from './types.js';
|
||||||
|
|
||||||
export type EmptyRequest = Record<string, unknown> | undefined;
|
export type EmptyRequest = Record<string, unknown> | undefined;
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
/*
|
|
||||||
* version: 2024.2.0-beta.8
|
|
||||||
* generatedAt: 2024-02-04T16:51:09.465Z
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { components } from './types.js';
|
import { components } from './types.js';
|
||||||
export type Error = components['schemas']['Error'];
|
export type Error = components['schemas']['Error'];
|
||||||
export type UserLite = components['schemas']['UserLite'];
|
export type UserLite = components['schemas']['UserLite'];
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
/* eslint @typescript-eslint/naming-convention: 0 */
|
/* eslint @typescript-eslint/naming-convention: 0 */
|
||||||
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
||||||
|
|
||||||
/*
|
|
||||||
* version: 2024.2.0-beta.8
|
|
||||||
* generatedAt: 2024-02-04T16:51:09.378Z
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file was auto-generated by openapi-typescript.
|
* This file was auto-generated by openapi-typescript.
|
||||||
* Do not make direct changes to the file.
|
* Do not make direct changes to the file.
|
||||||
|
Loading…
Reference in New Issue
Block a user