Skip to content

Commit bf898dc

Browse files
Core: comment in en
1 parent b22dec0 commit bf898dc

2 files changed

Lines changed: 43 additions & 57 deletions

File tree

packages/sdk/tsconfig.json

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
{
2-
"compilerOptions": {
3-
/* 語言 / Runtime */
4-
"target": "ES2019",
5-
"lib": ["ES2019", "DOM"],
6-
"useDefineForClassFields": true,
2+
"compilerOptions": {
3+
"target": "ES2019",
4+
"lib": ["ES2019", "DOM"],
5+
"useDefineForClassFields": true,
76

8-
/* Module */
9-
"module": "ESNext",
10-
"moduleResolution": "Bundler",
7+
"module": "ESNext",
8+
"moduleResolution": "Bundler",
119

12-
/* 輸出 */
13-
"rootDir": "src",
14-
"outDir": "dist",
15-
"declaration": true,
16-
"declarationMap": true,
17-
"emitDeclarationOnly": false,
18-
"sourceMap": true,
10+
"rootDir": "src",
11+
"outDir": "dist",
12+
"declaration": true,
13+
"declarationMap": true,
14+
"emitDeclarationOnly": false,
15+
"sourceMap": true,
1916

20-
/* 型別嚴謹度 */
21-
"strict": true,
22-
"exactOptionalPropertyTypes": true,
23-
"noUncheckedIndexedAccess": true,
17+
"strict": true,
18+
"exactOptionalPropertyTypes": true,
19+
"noUncheckedIndexedAccess": true,
2420

25-
/* DX / 穩定性 */
26-
"skipLibCheck": true,
27-
"forceConsistentCasingInFileNames": true
28-
},
29-
"include": ["src"]
21+
"skipLibCheck": true,
22+
"forceConsistentCasingInFileNames": true
23+
},
24+
"include": ["src"]
3025
}

scripts/patch-openapi.js

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,52 @@ const OPENAPI_PATH = "./tsp-output/schema/openapi.1.0.0.yaml";
55

66
const spec = yaml.load(readFileSync(OPENAPI_PATH, "utf8"));
77

8-
/* ------------------------------------------------------------------ */
9-
/* 0. Patch info (TypeSpec 無法表達的部分) */
10-
/* ------------------------------------------------------------------ */
11-
8+
// Patch OpenAPI spec
129
spec.info = {
13-
...spec.info,
14-
description: `
10+
...spec.info,
11+
description: `
1512
## Pages
1613
- [API Documentation (Redocly)](redocly/)
1714
- [API Documentation (Swagger UI)](swagger/)
1815
- [SDK Documentation (TypeDoc)](sdk/)
1916
`.trim(),
2017

21-
termsOfService: "https://sdc.nycu.club/terms",
18+
termsOfService: "https://sdc.nycu.club/terms",
2219

23-
contact: {
24-
name: "NYCU Software Development Club",
25-
email: "contact@sdc.nycu.club",
26-
url: "https://github.com/NYCU-SDC/core-system-api"
27-
},
20+
contact: {
21+
name: "NYCU Software Development Club",
22+
email: "contact@sdc.nycu.club",
23+
url: "https://github.com/NYCU-SDC/core-system-api",
24+
},
2825

29-
license: {
30-
name: "Apache-2.0",
31-
}
26+
license: {
27+
name: "Apache-2.0",
28+
},
3229
};
3330

34-
/* ------------------------------------------------------------------ */
35-
/* 1. 強制指定 requestBody 為 multipart/form-data */
36-
/* ------------------------------------------------------------------ */
37-
31+
// Patch OpenAPI spec
3832
const upload = spec.paths?.["/forms/{id}/cover"]?.post;
3933

4034
if (upload?.requestBody?.content) {
41-
const original = upload.requestBody.content["application/json"] ?? upload.requestBody.content[Object.keys(upload.requestBody.content)[0]];
35+
const original =
36+
upload.requestBody.content["application/json"] ??
37+
upload.requestBody.content[Object.keys(upload.requestBody.content)[0]];
4238

43-
upload.requestBody.content = {
44-
"multipart/form-data": original
45-
};
39+
upload.requestBody.content = {
40+
"multipart/form-data": original,
41+
};
4642
}
4743

48-
/* ------------------------------------------------------------------ */
49-
/* 2. 強制 binary 欄位 (file upload) */
50-
/* ------------------------------------------------------------------ */
51-
44+
// Force coverImage to be binary format
5245
const schema = spec.components?.schemas?.["Forms.FormCoverUploadRequest"];
5346

5447
if (schema?.properties?.coverImage) {
55-
schema.properties.coverImage = {
56-
type: "string",
57-
format: "binary"
58-
};
48+
schema.properties.coverImage = {
49+
type: "string",
50+
format: "binary",
51+
};
5952
}
6053

61-
/* ------------------------------------------------------------------ */
62-
6354
writeFileSync(OPENAPI_PATH, yaml.dump(spec, { lineWidth: -1 }), "utf8");
6455

6556
console.log("😉 Patched OpenAPI spec successfully.");

0 commit comments

Comments
 (0)