Skip to content

Commit e8b8a82

Browse files
Fix static content-type and error throw error on null status response
1 parent bf1fefc commit e8b8a82

File tree

1 file changed

+95
-33
lines changed

1 file changed

+95
-33
lines changed

src/sdk/sdk.ts

Lines changed: 95 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export class SDK {
7878
break;
7979
}
8080

81-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
81+
if (httpRes?.status != null)
82+
throw new Error(`status code not found in response: ${httpRes}`);
83+
res.StatusCode = httpRes.status;
8284
res.ContentType = contentType;
8385

8486
return res;
@@ -119,7 +121,9 @@ export class SDK {
119121
break;
120122
}
121123

122-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
124+
if (httpRes?.status != null)
125+
throw new Error(`status code not found in response: ${httpRes}`);
126+
res.StatusCode = httpRes.status;
123127
res.ContentType = contentType;
124128

125129
return res;
@@ -160,7 +164,9 @@ export class SDK {
160164
break;
161165
}
162166

163-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
167+
if (httpRes?.status != null)
168+
throw new Error(`status code not found in response: ${httpRes}`);
169+
res.StatusCode = httpRes.status;
164170
res.ContentType = contentType;
165171

166172
return res;
@@ -201,7 +207,9 @@ export class SDK {
201207
break;
202208
}
203209

204-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
210+
if (httpRes?.status != null)
211+
throw new Error(`status code not found in response: ${httpRes}`);
212+
res.StatusCode = httpRes.status;
205213
res.ContentType = contentType;
206214

207215
return res;
@@ -237,7 +245,7 @@ export class SDK {
237245
case 200:
238246
if (MatchContentType(contentType, "application/json"))
239247
res.Schema = httpRes?.data;
240-
if (MatchContentType(contentType, "application/json"))
248+
if (MatchContentType(contentType, "application/x-yaml"))
241249
res.Schema = httpRes?.data;
242250
break;
243251
default:
@@ -246,7 +254,9 @@ export class SDK {
246254
break;
247255
}
248256

249-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
257+
if (httpRes?.status != null)
258+
throw new Error(`status code not found in response: ${httpRes}`);
259+
res.StatusCode = httpRes.status;
250260
res.ContentType = contentType;
251261

252262
return res;
@@ -282,7 +292,7 @@ export class SDK {
282292
case 200:
283293
if (MatchContentType(contentType, "application/json"))
284294
res.Schema = httpRes?.data;
285-
if (MatchContentType(contentType, "application/json"))
295+
if (MatchContentType(contentType, "application/x-yaml"))
286296
res.Schema = httpRes?.data;
287297
break;
288298
default:
@@ -291,7 +301,9 @@ export class SDK {
291301
break;
292302
}
293303

294-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
304+
if (httpRes?.status != null)
305+
throw new Error(`status code not found in response: ${httpRes}`);
306+
res.StatusCode = httpRes.status;
295307
res.ContentType = contentType;
296308

297309
return res;
@@ -334,7 +346,9 @@ export class SDK {
334346
break;
335347
}
336348

337-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
349+
if (httpRes?.status != null)
350+
throw new Error(`status code not found in response: ${httpRes}`);
351+
res.StatusCode = httpRes.status;
338352
res.ContentType = contentType;
339353

340354
return res;
@@ -377,7 +391,9 @@ export class SDK {
377391
break;
378392
}
379393

380-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
394+
if (httpRes?.status != null)
395+
throw new Error(`status code not found in response: ${httpRes}`);
396+
res.StatusCode = httpRes.status;
381397
res.ContentType = contentType;
382398

383399
return res;
@@ -422,7 +438,9 @@ export class SDK {
422438
break;
423439
}
424440

425-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
441+
if (httpRes?.status != null)
442+
throw new Error(`status code not found in response: ${httpRes}`);
443+
res.StatusCode = httpRes.status;
426444
res.ContentType = contentType;
427445

428446
return res;
@@ -465,7 +483,9 @@ export class SDK {
465483
break;
466484
}
467485

468-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
486+
if (httpRes?.status != null)
487+
throw new Error(`status code not found in response: ${httpRes}`);
488+
res.StatusCode = httpRes.status;
469489
res.ContentType = contentType;
470490

471491
return res;
@@ -510,7 +530,9 @@ export class SDK {
510530
break;
511531
}
512532

513-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
533+
if (httpRes?.status != null)
534+
throw new Error(`status code not found in response: ${httpRes}`);
535+
res.StatusCode = httpRes.status;
514536
res.ContentType = contentType;
515537

516538
return res;
@@ -555,7 +577,9 @@ export class SDK {
555577
break;
556578
}
557579

558-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
580+
if (httpRes?.status != null)
581+
throw new Error(`status code not found in response: ${httpRes}`);
582+
res.StatusCode = httpRes.status;
559583
res.ContentType = contentType;
560584

561585
return res;
@@ -598,7 +622,9 @@ export class SDK {
598622
break;
599623
}
600624

601-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
625+
if (httpRes?.status != null)
626+
throw new Error(`status code not found in response: ${httpRes}`);
627+
res.StatusCode = httpRes.status;
602628
res.ContentType = contentType;
603629

604630
return res;
@@ -651,7 +677,9 @@ export class SDK {
651677
break;
652678
}
653679

654-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
680+
if (httpRes?.status != null)
681+
throw new Error(`status code not found in response: ${httpRes}`);
682+
res.StatusCode = httpRes.status;
655683
res.ContentType = contentType;
656684

657685
return res;
@@ -694,7 +722,9 @@ export class SDK {
694722
break;
695723
}
696724

697-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
725+
if (httpRes?.status != null)
726+
throw new Error(`status code not found in response: ${httpRes}`);
727+
res.StatusCode = httpRes.status;
698728
res.ContentType = contentType;
699729

700730
return res;
@@ -737,7 +767,9 @@ export class SDK {
737767
break;
738768
}
739769

740-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
770+
if (httpRes?.status != null)
771+
throw new Error(`status code not found in response: ${httpRes}`);
772+
res.StatusCode = httpRes.status;
741773
res.ContentType = contentType;
742774

743775
return res;
@@ -786,7 +818,9 @@ export class SDK {
786818
break;
787819
}
788820

789-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
821+
if (httpRes?.status != null)
822+
throw new Error(`status code not found in response: ${httpRes}`);
823+
res.StatusCode = httpRes.status;
790824
res.ContentType = contentType;
791825

792826
return res;
@@ -836,7 +870,9 @@ export class SDK {
836870
break;
837871
}
838872

839-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
873+
if (httpRes?.status != null)
874+
throw new Error(`status code not found in response: ${httpRes}`);
875+
res.StatusCode = httpRes.status;
840876
res.ContentType = contentType;
841877

842878
return res;
@@ -879,7 +915,9 @@ export class SDK {
879915
break;
880916
}
881917

882-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
918+
if (httpRes?.status != null)
919+
throw new Error(`status code not found in response: ${httpRes}`);
920+
res.StatusCode = httpRes.status;
883921
res.ContentType = contentType;
884922

885923
return res;
@@ -922,7 +960,9 @@ export class SDK {
922960
break;
923961
}
924962

925-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
963+
if (httpRes?.status != null)
964+
throw new Error(`status code not found in response: ${httpRes}`);
965+
res.StatusCode = httpRes.status;
926966
res.ContentType = contentType;
927967

928968
return res;
@@ -965,7 +1005,9 @@ export class SDK {
9651005
break;
9661006
}
9671007

968-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1008+
if (httpRes?.status != null)
1009+
throw new Error(`status code not found in response: ${httpRes}`);
1010+
res.StatusCode = httpRes.status;
9691011
res.ContentType = contentType;
9701012

9711013
return res;
@@ -1008,7 +1050,9 @@ export class SDK {
10081050
break;
10091051
}
10101052

1011-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1053+
if (httpRes?.status != null)
1054+
throw new Error(`status code not found in response: ${httpRes}`);
1055+
res.StatusCode = httpRes.status;
10121056
res.ContentType = contentType;
10131057

10141058
return res;
@@ -1051,7 +1095,9 @@ export class SDK {
10511095
break;
10521096
}
10531097

1054-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1098+
if (httpRes?.status != null)
1099+
throw new Error(`status code not found in response: ${httpRes}`);
1100+
res.StatusCode = httpRes.status;
10551101
res.ContentType = contentType;
10561102

10571103
return res;
@@ -1090,7 +1136,9 @@ export class SDK {
10901136
break;
10911137
}
10921138

1093-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1139+
if (httpRes?.status != null)
1140+
throw new Error(`status code not found in response: ${httpRes}`);
1141+
res.StatusCode = httpRes.status;
10941142
res.ContentType = contentType;
10951143

10961144
return res;
@@ -1133,7 +1181,9 @@ export class SDK {
11331181
break;
11341182
}
11351183

1136-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1184+
if (httpRes?.status != null)
1185+
throw new Error(`status code not found in response: ${httpRes}`);
1186+
res.StatusCode = httpRes.status;
11371187
res.ContentType = contentType;
11381188

11391189
return res;
@@ -1192,7 +1242,9 @@ export class SDK {
11921242
break;
11931243
}
11941244

1195-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1245+
if (httpRes?.status != null)
1246+
throw new Error(`status code not found in response: ${httpRes}`);
1247+
res.StatusCode = httpRes.status;
11961248
res.ContentType = contentType;
11971249

11981250
return res;
@@ -1241,7 +1293,9 @@ export class SDK {
12411293
break;
12421294
}
12431295

1244-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1296+
if (httpRes?.status != null)
1297+
throw new Error(`status code not found in response: ${httpRes}`);
1298+
res.StatusCode = httpRes.status;
12451299
res.ContentType = contentType;
12461300

12471301
return res;
@@ -1298,7 +1352,9 @@ export class SDK {
12981352
break;
12991353
}
13001354

1301-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1355+
if (httpRes?.status != null)
1356+
throw new Error(`status code not found in response: ${httpRes}`);
1357+
res.StatusCode = httpRes.status;
13021358
res.ContentType = contentType;
13031359

13041360
return res;
@@ -1339,7 +1395,9 @@ export class SDK {
13391395
break;
13401396
}
13411397

1342-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1398+
if (httpRes?.status != null)
1399+
throw new Error(`status code not found in response: ${httpRes}`);
1400+
res.StatusCode = httpRes.status;
13431401
res.ContentType = contentType;
13441402

13451403
return res;
@@ -1398,7 +1456,9 @@ export class SDK {
13981456
break;
13991457
}
14001458

1401-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1459+
if (httpRes?.status != null)
1460+
throw new Error(`status code not found in response: ${httpRes}`);
1461+
res.StatusCode = httpRes.status;
14021462
res.ContentType = contentType;
14031463

14041464
return res;
@@ -1457,7 +1517,9 @@ export class SDK {
14571517
break;
14581518
}
14591519

1460-
if (httpRes?.status != null) res.StatusCode = httpRes.status;
1520+
if (httpRes?.status != null)
1521+
throw new Error(`status code not found in response: ${httpRes}`);
1522+
res.StatusCode = httpRes.status;
14611523
res.ContentType = contentType;
14621524

14631525
return res;

0 commit comments

Comments
 (0)