Skip to content

Commit 284f660

Browse files
committed
fix: styles
1 parent fd473f5 commit 284f660

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

scripts/apply.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs, { writeFile } from "fs";
1+
import fs from "fs";
22
import { OpenAPIV3_1 } from "openapi-types";
33
import argv from "yargs-parser";
44
import { promisify } from "util";
@@ -21,14 +21,14 @@ function findParamFromRef(ref: string, openapi: OpenAPIV3_1.Document): OpenAPIV3
2121
}
2222

2323
async function main() {
24-
const {spec, file} = argv(process.argv.slice(2));
24+
const { spec, file } = argv(process.argv.slice(2));
2525

2626
if (!spec || !file) {
2727
console.error("Please provide both --spec and --file arguments.");
2828
process.exit(1);
2929
}
3030

31-
const specFile = await readFileAsync(spec, "utf8") as string;
31+
const specFile = (await readFileAsync(spec, "utf8")) as string;
3232

3333
const operations: {
3434
path: string;
@@ -42,7 +42,7 @@ async function main() {
4242
for (const path in openapi.paths) {
4343
for (const method in openapi.paths[path]) {
4444
const operation: OpenAPIV3_1.OperationObject = openapi.paths[path][method];
45-
45+
4646
if (!operation.operationId || !operation.tags?.length) {
4747
continue;
4848
}
@@ -63,24 +63,29 @@ async function main() {
6363
operations.push({
6464
path,
6565
method: method.toUpperCase(),
66-
operationId: operation.operationId || '',
66+
operationId: operation.operationId || "",
6767
requiredParams,
6868
tag: operation.tags[0],
6969
});
7070
}
7171
}
72-
73-
const operationOutput = operations.map((operation) => {
74-
const { operationId, method, path, requiredParams } = operation;
75-
return `async ${operationId}(options${requiredParams ? '' : '?'}: FetchOptions<operations["${operationId}"]>) {
72+
73+
const operationOutput = operations
74+
.map((operation) => {
75+
const { operationId, method, path, requiredParams } = operation;
76+
return `async ${operationId}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
7677
const { data } = await this.client.${method}("${path}", options);
7778
return data;
7879
}
7980
`;
80-
}).join("\n");
81+
})
82+
.join("\n");
8183

82-
const templateFile = await readFileAsync(file, "utf8") as string;
83-
const output = templateFile.replace(/\/\/ DO NOT EDIT\. This is auto-generated code\.\n.*\/\/ DO NOT EDIT\. This is auto-generated code\./g, operationOutput);
84+
const templateFile = (await readFileAsync(file, "utf8")) as string;
85+
const output = templateFile.replace(
86+
/\/\/ DO NOT EDIT\. This is auto-generated code\.\n.*\/\/ DO NOT EDIT\. This is auto-generated code\./g,
87+
operationOutput
88+
);
8489

8590
await writeFileAsync(file, output, "utf8");
8691
}

0 commit comments

Comments
 (0)