[typescript] Add headers to ApiException (#10153)

This commit is contained in:
Jordan M. Adler
2021-10-21 23:50:03 -07:00
committed by GitHub
parent 37006f8a03
commit e7dace6099
24 changed files with 257 additions and 250 deletions

View File

@@ -200,7 +200,7 @@ export class {{classname}}ResponseProcessor {
return body;
{{/is2xx}}
{{^is2xx}}
throw new ApiException<{{{dataType}}}>({{code}}, "{{message}}", body);
throw new ApiException<{{{dataType}}}>({{code}}, "{{message}}", body, response.headers);
{{/is2xx}}
{{/dataType}}
{{^dataType}}
@@ -208,7 +208,7 @@ export class {{classname}}ResponseProcessor {
return;
{{/is2xx}}
{{^is2xx}}
throw new ApiException<undefined>(response.httpStatusCode, "{{message}}", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "{{message}}", undefined, response.headers);
{{/is2xx}}
{{/dataType}}
}
@@ -233,7 +233,7 @@ export class {{classname}}ResponseProcessor {
{{/returnType}}
}
throw new ApiException<string | {{{fileContentDataType}}} | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | {{{fileContentDataType}}} | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
{{/operation}}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}

View File

@@ -134,7 +134,7 @@ export class DefaultApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -159,7 +159,7 @@ export class DefaultApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -184,7 +184,7 @@ export class DefaultApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}

View File

@@ -402,7 +402,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -414,7 +414,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -427,7 +427,7 @@ export class PetApiResponseProcessor {
public async deletePet(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -435,7 +435,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -455,7 +455,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -467,7 +467,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -487,7 +487,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -499,7 +499,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -519,10 +519,10 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -534,7 +534,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -554,13 +554,13 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -572,7 +572,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -585,7 +585,7 @@ export class PetApiResponseProcessor {
public async updatePetWithForm(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -593,7 +593,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -622,7 +622,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -145,10 +145,10 @@ export class StoreApiResponseProcessor {
public async deleteOrder(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -156,7 +156,7 @@ export class StoreApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -185,7 +185,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -205,10 +205,10 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -220,7 +220,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -240,7 +240,7 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -252,7 +252,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -333,7 +333,7 @@ export class UserApiResponseProcessor {
public async createUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -341,7 +341,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -354,7 +354,7 @@ export class UserApiResponseProcessor {
public async createUsersWithArrayInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -362,7 +362,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -375,7 +375,7 @@ export class UserApiResponseProcessor {
public async createUsersWithListInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -383,7 +383,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -396,10 +396,10 @@ export class UserApiResponseProcessor {
public async deleteUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -407,7 +407,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -427,10 +427,10 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -442,7 +442,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -462,7 +462,7 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -474,7 +474,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -487,7 +487,7 @@ export class UserApiResponseProcessor {
public async logoutUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -495,7 +495,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -508,10 +508,10 @@ export class UserApiResponseProcessor {
public async updateUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -519,7 +519,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}

View File

@@ -400,7 +400,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -412,7 +412,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -425,7 +425,7 @@ export class PetApiResponseProcessor {
public async deletePet(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -433,7 +433,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -453,7 +453,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -465,7 +465,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -485,7 +485,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -497,7 +497,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -517,10 +517,10 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -532,7 +532,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -552,13 +552,13 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -570,7 +570,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -583,7 +583,7 @@ export class PetApiResponseProcessor {
public async updatePetWithForm(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -591,7 +591,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -620,7 +620,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -143,10 +143,10 @@ export class StoreApiResponseProcessor {
public async deleteOrder(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -154,7 +154,7 @@ export class StoreApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -183,7 +183,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -203,10 +203,10 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -218,7 +218,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -238,7 +238,7 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -250,7 +250,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -331,7 +331,7 @@ export class UserApiResponseProcessor {
public async createUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -339,7 +339,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -352,7 +352,7 @@ export class UserApiResponseProcessor {
public async createUsersWithArrayInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -360,7 +360,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -373,7 +373,7 @@ export class UserApiResponseProcessor {
public async createUsersWithListInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -381,7 +381,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -394,10 +394,10 @@ export class UserApiResponseProcessor {
public async deleteUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -405,7 +405,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -425,10 +425,10 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -440,7 +440,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -460,7 +460,7 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -472,7 +472,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -485,7 +485,7 @@ export class UserApiResponseProcessor {
public async logoutUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -493,7 +493,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -506,10 +506,10 @@ export class UserApiResponseProcessor {
public async updateUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -517,7 +517,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}

View File

@@ -405,7 +405,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -417,7 +417,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -430,7 +430,7 @@ export class PetApiResponseProcessor {
public async deletePet(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -438,7 +438,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -458,7 +458,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -470,7 +470,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -490,7 +490,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -502,7 +502,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -522,10 +522,10 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -537,7 +537,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -557,13 +557,13 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -575,7 +575,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -588,7 +588,7 @@ export class PetApiResponseProcessor {
public async updatePetWithForm(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -596,7 +596,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -625,7 +625,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -148,10 +148,10 @@ export class StoreApiResponseProcessor {
public async deleteOrder(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -159,7 +159,7 @@ export class StoreApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -188,7 +188,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -208,10 +208,10 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -223,7 +223,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -243,7 +243,7 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -255,7 +255,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -336,7 +336,7 @@ export class UserApiResponseProcessor {
public async createUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -344,7 +344,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -357,7 +357,7 @@ export class UserApiResponseProcessor {
public async createUsersWithArrayInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -365,7 +365,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -378,7 +378,7 @@ export class UserApiResponseProcessor {
public async createUsersWithListInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -386,7 +386,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -399,10 +399,10 @@ export class UserApiResponseProcessor {
public async deleteUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -410,7 +410,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -430,10 +430,10 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -445,7 +445,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -465,7 +465,7 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -477,7 +477,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -490,7 +490,7 @@ export class UserApiResponseProcessor {
public async logoutUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -498,7 +498,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -511,10 +511,10 @@ export class UserApiResponseProcessor {
public async updateUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -522,7 +522,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}

View File

@@ -400,7 +400,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -412,7 +412,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -425,7 +425,7 @@ export class PetApiResponseProcessor {
public async deletePet(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -433,7 +433,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -453,7 +453,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -465,7 +465,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -485,7 +485,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -497,7 +497,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -517,10 +517,10 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -532,7 +532,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -552,13 +552,13 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -570,7 +570,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -583,7 +583,7 @@ export class PetApiResponseProcessor {
public async updatePetWithForm(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -591,7 +591,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -620,7 +620,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -143,10 +143,10 @@ export class StoreApiResponseProcessor {
public async deleteOrder(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -154,7 +154,7 @@ export class StoreApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -183,7 +183,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -203,10 +203,10 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -218,7 +218,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -238,7 +238,7 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -250,7 +250,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -331,7 +331,7 @@ export class UserApiResponseProcessor {
public async createUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -339,7 +339,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -352,7 +352,7 @@ export class UserApiResponseProcessor {
public async createUsersWithArrayInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -360,7 +360,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -373,7 +373,7 @@ export class UserApiResponseProcessor {
public async createUsersWithListInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -381,7 +381,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -394,10 +394,10 @@ export class UserApiResponseProcessor {
public async deleteUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -405,7 +405,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -425,10 +425,10 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -440,7 +440,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -460,7 +460,7 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -472,7 +472,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -485,7 +485,7 @@ export class UserApiResponseProcessor {
public async logoutUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -493,7 +493,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -506,10 +506,10 @@ export class UserApiResponseProcessor {
public async updateUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -517,7 +517,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}

View File

@@ -402,7 +402,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -414,7 +414,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -427,7 +427,7 @@ export class PetApiResponseProcessor {
public async deletePet(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -435,7 +435,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -455,7 +455,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -467,7 +467,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -487,7 +487,7 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -499,7 +499,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -519,10 +519,10 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -534,7 +534,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -554,13 +554,13 @@ export class PetApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
}
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -572,7 +572,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -585,7 +585,7 @@ export class PetApiResponseProcessor {
public async updatePetWithForm(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("405", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -593,7 +593,7 @@ export class PetApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -622,7 +622,7 @@ export class PetApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -145,10 +145,10 @@ export class StoreApiResponseProcessor {
public async deleteOrder(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -156,7 +156,7 @@ export class StoreApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -185,7 +185,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -205,10 +205,10 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -220,7 +220,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -240,7 +240,7 @@ export class StoreApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -252,7 +252,7 @@ export class StoreApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -333,7 +333,7 @@ export class UserApiResponseProcessor {
public async createUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -341,7 +341,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -354,7 +354,7 @@ export class UserApiResponseProcessor {
public async createUsersWithArrayInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -362,7 +362,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -375,7 +375,7 @@ export class UserApiResponseProcessor {
public async createUsersWithListInput(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -383,7 +383,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -396,10 +396,10 @@ export class UserApiResponseProcessor {
public async deleteUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -407,7 +407,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -427,10 +427,10 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -442,7 +442,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -462,7 +462,7 @@ export class UserApiResponseProcessor {
return body;
}
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -474,7 +474,7 @@ export class UserApiResponseProcessor {
return body;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -487,7 +487,7 @@ export class UserApiResponseProcessor {
public async logoutUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -495,7 +495,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
@@ -508,10 +508,10 @@ export class UserApiResponseProcessor {
public async updateUser(response: ResponseContext): Promise< void> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("400", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined, response.headers);
}
if (isCodeInRange("404", response.httpStatusCode)) {
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -519,7 +519,7 @@ export class UserApiResponseProcessor {
return;
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny());
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@@ -8,7 +8,8 @@
*
*/
export class ApiException<T> extends Error {
public constructor(public code: number, message: string, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body))
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
JSON.stringify(headers))
}
}