|
3 | 3 | */
|
4 | 4 |
|
5 | 5 | import * as utils from "../internal/utils";
|
| 6 | +import * as errors from "./models/errors"; |
6 | 7 | import * as operations from "./models/operations";
|
7 | 8 | import * as shared from "./models/shared";
|
8 | 9 | import { SDKConfiguration } from "./sdk";
|
@@ -78,6 +79,13 @@ export class ApiEndpoints {
|
78 | 79 | default:
|
79 | 80 | if (utils.matchContentType(contentType, `application/json`)) {
|
80 | 81 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 82 | + } else { |
| 83 | + throw new errors.SDKError( |
| 84 | + "unknown content-type received: " + contentType, |
| 85 | + httpRes.status, |
| 86 | + decodedRes, |
| 87 | + httpRes |
| 88 | + ); |
81 | 89 | }
|
82 | 90 | break;
|
83 | 91 | }
|
@@ -147,11 +155,25 @@ export class ApiEndpoints {
|
147 | 155 | JSON.parse(decodedRes),
|
148 | 156 | shared.ApiEndpoint
|
149 | 157 | );
|
| 158 | + } else { |
| 159 | + throw new errors.SDKError( |
| 160 | + "unknown content-type received: " + contentType, |
| 161 | + httpRes.status, |
| 162 | + decodedRes, |
| 163 | + httpRes |
| 164 | + ); |
150 | 165 | }
|
151 | 166 | break;
|
152 | 167 | default:
|
153 | 168 | if (utils.matchContentType(contentType, `application/json`)) {
|
154 | 169 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 170 | + } else { |
| 171 | + throw new errors.SDKError( |
| 172 | + "unknown content-type received: " + contentType, |
| 173 | + httpRes.status, |
| 174 | + decodedRes, |
| 175 | + httpRes |
| 176 | + ); |
155 | 177 | }
|
156 | 178 | break;
|
157 | 179 | }
|
@@ -222,11 +244,25 @@ export class ApiEndpoints {
|
222 | 244 | JSON.parse(decodedRes),
|
223 | 245 | shared.GenerateOpenApiSpecDiff
|
224 | 246 | );
|
| 247 | + } else { |
| 248 | + throw new errors.SDKError( |
| 249 | + "unknown content-type received: " + contentType, |
| 250 | + httpRes.status, |
| 251 | + decodedRes, |
| 252 | + httpRes |
| 253 | + ); |
225 | 254 | }
|
226 | 255 | break;
|
227 | 256 | default:
|
228 | 257 | if (utils.matchContentType(contentType, `application/json`)) {
|
229 | 258 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 259 | + } else { |
| 260 | + throw new errors.SDKError( |
| 261 | + "unknown content-type received: " + contentType, |
| 262 | + httpRes.status, |
| 263 | + decodedRes, |
| 264 | + httpRes |
| 265 | + ); |
230 | 266 | }
|
231 | 267 | break;
|
232 | 268 | }
|
@@ -293,11 +329,25 @@ export class ApiEndpoints {
|
293 | 329 | case httpRes?.status == 200:
|
294 | 330 | if (utils.matchContentType(contentType, `application/octet-stream`)) {
|
295 | 331 | res.postmanCollection = httpRes?.data;
|
| 332 | + } else { |
| 333 | + throw new errors.SDKError( |
| 334 | + "unknown content-type received: " + contentType, |
| 335 | + httpRes.status, |
| 336 | + decodedRes, |
| 337 | + httpRes |
| 338 | + ); |
296 | 339 | }
|
297 | 340 | break;
|
298 | 341 | default:
|
299 | 342 | if (utils.matchContentType(contentType, `application/json`)) {
|
300 | 343 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 344 | + } else { |
| 345 | + throw new errors.SDKError( |
| 346 | + "unknown content-type received: " + contentType, |
| 347 | + httpRes.status, |
| 348 | + decodedRes, |
| 349 | + httpRes |
| 350 | + ); |
301 | 351 | }
|
302 | 352 | break;
|
303 | 353 | }
|
@@ -363,11 +413,25 @@ export class ApiEndpoints {
|
363 | 413 | shared.ApiEndpoint,
|
364 | 414 | resFieldDepth
|
365 | 415 | );
|
| 416 | + } else { |
| 417 | + throw new errors.SDKError( |
| 418 | + "unknown content-type received: " + contentType, |
| 419 | + httpRes.status, |
| 420 | + decodedRes, |
| 421 | + httpRes |
| 422 | + ); |
366 | 423 | }
|
367 | 424 | break;
|
368 | 425 | default:
|
369 | 426 | if (utils.matchContentType(contentType, `application/json`)) {
|
370 | 427 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 428 | + } else { |
| 429 | + throw new errors.SDKError( |
| 430 | + "unknown content-type received: " + contentType, |
| 431 | + httpRes.status, |
| 432 | + decodedRes, |
| 433 | + httpRes |
| 434 | + ); |
371 | 435 | }
|
372 | 436 | break;
|
373 | 437 | }
|
@@ -437,11 +501,25 @@ export class ApiEndpoints {
|
437 | 501 | shared.ApiEndpoint,
|
438 | 502 | resFieldDepth
|
439 | 503 | );
|
| 504 | + } else { |
| 505 | + throw new errors.SDKError( |
| 506 | + "unknown content-type received: " + contentType, |
| 507 | + httpRes.status, |
| 508 | + decodedRes, |
| 509 | + httpRes |
| 510 | + ); |
440 | 511 | }
|
441 | 512 | break;
|
442 | 513 | default:
|
443 | 514 | if (utils.matchContentType(contentType, `application/json`)) {
|
444 | 515 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 516 | + } else { |
| 517 | + throw new errors.SDKError( |
| 518 | + "unknown content-type received: " + contentType, |
| 519 | + httpRes.status, |
| 520 | + decodedRes, |
| 521 | + httpRes |
| 522 | + ); |
445 | 523 | }
|
446 | 524 | break;
|
447 | 525 | }
|
@@ -507,11 +585,25 @@ export class ApiEndpoints {
|
507 | 585 | JSON.parse(decodedRes),
|
508 | 586 | shared.ApiEndpoint
|
509 | 587 | );
|
| 588 | + } else { |
| 589 | + throw new errors.SDKError( |
| 590 | + "unknown content-type received: " + contentType, |
| 591 | + httpRes.status, |
| 592 | + decodedRes, |
| 593 | + httpRes |
| 594 | + ); |
510 | 595 | }
|
511 | 596 | break;
|
512 | 597 | default:
|
513 | 598 | if (utils.matchContentType(contentType, `application/json`)) {
|
514 | 599 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 600 | + } else { |
| 601 | + throw new errors.SDKError( |
| 602 | + "unknown content-type received: " + contentType, |
| 603 | + httpRes.status, |
| 604 | + decodedRes, |
| 605 | + httpRes |
| 606 | + ); |
515 | 607 | }
|
516 | 608 | break;
|
517 | 609 | }
|
@@ -593,11 +685,25 @@ export class ApiEndpoints {
|
593 | 685 | JSON.parse(decodedRes),
|
594 | 686 | shared.ApiEndpoint
|
595 | 687 | );
|
| 688 | + } else { |
| 689 | + throw new errors.SDKError( |
| 690 | + "unknown content-type received: " + contentType, |
| 691 | + httpRes.status, |
| 692 | + decodedRes, |
| 693 | + httpRes |
| 694 | + ); |
596 | 695 | }
|
597 | 696 | break;
|
598 | 697 | default:
|
599 | 698 | if (utils.matchContentType(contentType, `application/json`)) {
|
600 | 699 | res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
|
| 700 | + } else { |
| 701 | + throw new errors.SDKError( |
| 702 | + "unknown content-type received: " + contentType, |
| 703 | + httpRes.status, |
| 704 | + decodedRes, |
| 705 | + httpRes |
| 706 | + ); |
601 | 707 | }
|
602 | 708 | break;
|
603 | 709 | }
|
|
0 commit comments