@@ -5,61 +5,52 @@ const OPENAPI_PATH = "./tsp-output/schema/openapi.1.0.0.yaml";
55
66const spec = yaml . load ( readFileSync ( OPENAPI_PATH , "utf8" ) ) ;
77
8- /* ------------------------------------------------------------------ */
9- /* 0. Patch info (TypeSpec 無法表達的部分) */
10- /* ------------------------------------------------------------------ */
11-
8+ // Patch OpenAPI spec
129spec . 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
3832const upload = spec . paths ?. [ "/forms/{id}/cover" ] ?. post ;
3933
4034if ( 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
5245const schema = spec . components ?. schemas ?. [ "Forms.FormCoverUploadRequest" ] ;
5346
5447if ( 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-
6354writeFileSync ( OPENAPI_PATH , yaml . dump ( spec , { lineWidth : - 1 } ) , "utf8" ) ;
6455
6556console . log ( "😉 Patched OpenAPI spec successfully." ) ;
0 commit comments