Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ 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}}
{{#is2xx}}
return;
{{/is2xx}}
{{^is2xx}}
throw new ApiException<undefined>(response.httpStatusCode, "{{message}}", undefined);
throw new ApiException<undefined>(response.httpStatusCode, "{{message}}", undefined, response.headers);
{{/is2xx}}
{{/dataType}}
}
Expand All @@ -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);
Comment thread
macjohnny marked this conversation as resolved.
}

{{/operation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -427,15 +427,15 @@ 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
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
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);
}

/**
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -585,15 +585,15 @@ 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
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
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);
}

/**
Expand Down Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,18 @@ 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
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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);
}

}
Loading