Merge remote-tracking branch 'misskey/master' into feature/2024.9.0
This commit is contained in:
@@ -7,15 +7,15 @@
|
||||
"generate": "tsx src/generator.ts && eslint ./built/**/*.ts --fix --cache"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@readme/openapi-parser": "2.5.0",
|
||||
"@readme/openapi-parser": "2.6.0",
|
||||
"@types/node": "20.9.1",
|
||||
"@typescript-eslint/eslint-plugin": "6.11.0",
|
||||
"@typescript-eslint/parser": "6.11.0",
|
||||
"@typescript-eslint/eslint-plugin": "7.17.0",
|
||||
"@typescript-eslint/parser": "7.17.0",
|
||||
"openapi-types": "12.1.3",
|
||||
"openapi-typescript": "6.7.3",
|
||||
"ts-case-convert": "2.0.2",
|
||||
"ts-case-convert": "2.0.7",
|
||||
"tsx": "4.4.0",
|
||||
"typescript": "5.3.3"
|
||||
"typescript": "5.6.2"
|
||||
},
|
||||
"files": [
|
||||
"built"
|
||||
|
||||
@@ -96,15 +96,11 @@ async function generateEndpoints(
|
||||
endpoint.request = req;
|
||||
|
||||
const reqType = new EndpointReqMediaType(path, req);
|
||||
endpointReqMediaTypesSet.add(reqType.getMediaType());
|
||||
endpointReqMediaTypes.push(reqType);
|
||||
} else {
|
||||
endpointReqMediaTypesSet.add('application/json');
|
||||
endpointReqMediaTypes.push(new EndpointReqMediaType(path, undefined, 'application/json'));
|
||||
if (reqType.getMediaType() !== 'application/json') {
|
||||
endpointReqMediaTypesSet.add(reqType.getMediaType());
|
||||
endpointReqMediaTypes.push(reqType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
endpointReqMediaTypesSet.add('application/json');
|
||||
endpointReqMediaTypes.push(new EndpointReqMediaType(path, undefined, 'application/json'));
|
||||
}
|
||||
|
||||
if (operation.responses && isResponseObject(operation.responses['200']) && operation.responses['200'].content) {
|
||||
@@ -158,16 +154,19 @@ async function generateEndpoints(
|
||||
endpointOutputLine.push('');
|
||||
|
||||
function generateEndpointReqMediaTypesType() {
|
||||
return `Record<keyof Endpoints, ${[...endpointReqMediaTypesSet].map((t) => `'${t}'`).join(' | ')}>`;
|
||||
return `{ [K in keyof Endpoints]?: ${[...endpointReqMediaTypesSet].map((t) => `'${t}'`).join(' | ')}; }`;
|
||||
}
|
||||
|
||||
endpointOutputLine.push(`export const endpointReqTypes: ${generateEndpointReqMediaTypesType()} = {`);
|
||||
endpointOutputLine.push(`/**
|
||||
* NOTE: The content-type for all endpoints not listed here is application/json.
|
||||
*/`);
|
||||
endpointOutputLine.push('export const endpointReqTypes = {');
|
||||
|
||||
endpointOutputLine.push(
|
||||
...endpointReqMediaTypes.map(it => '\t' + it.toLine()),
|
||||
);
|
||||
|
||||
endpointOutputLine.push('};');
|
||||
endpointOutputLine.push(`} as const satisfies ${generateEndpointReqMediaTypesType()};`);
|
||||
endpointOutputLine.push('');
|
||||
|
||||
await writeFile(endpointOutputPath, endpointOutputLine.join('\n'));
|
||||
|
||||
Reference in New Issue
Block a user