forked from loafle/openapi-generator-original
Additional tests for pet store api
This commit is contained in:
parent
c5c9a59060
commit
1c2943dcc8
@ -32,17 +32,18 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}});
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.{{httpMethod}});
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
if ({{paramName}} !== undefined) {
|
if ({{paramName}} !== undefined) {
|
||||||
requestContext.setQueryParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"));
|
requestContext.setQueryParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"));
|
||||||
}
|
}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
requestContext.setHeaderParam("{{basename}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"));
|
requestContext.setHeaderParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"));
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
|
|
||||||
// Form Params
|
// Form Params
|
||||||
@ -154,7 +155,8 @@ export class {{classname}}ResponseProcessor {
|
|||||||
return;
|
return;
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export class ApiException<T> extends Error {
|
export class ApiException<T> extends Error {
|
||||||
public constructor(public code: number, public body: T) {
|
public constructor(public code: number, public body: T) {
|
||||||
super("Got HTTP Status Code " + code)
|
super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,7 +24,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -62,11 +63,12 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
requestContext.setHeaderParam("", ObjectSerializer.serialize(apiKey, "string"));
|
requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string"));
|
||||||
|
|
||||||
// Form Params
|
// Form Params
|
||||||
|
|
||||||
@ -95,10 +97,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
if (status !== undefined) {
|
if (status !== undefined) {
|
||||||
requestContext.setQueryParam("", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>"));
|
requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -130,10 +133,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
if (tags !== undefined) {
|
if (tags !== undefined) {
|
||||||
requestContext.setQueryParam("", ObjectSerializer.serialize(tags, "Array<string>"));
|
requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array<string>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -166,7 +170,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -198,7 +203,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -236,7 +242,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -279,7 +286,8 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -330,7 +338,8 @@ export class PetApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,7 +355,8 @@ export class PetApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +379,8 @@ export class PetApiResponseProcessor {
|
|||||||
const body: Array<Pet> = ObjectSerializer.deserialize(jsonBody, "Array<Pet>") as Array<Pet>;
|
const body: Array<Pet> = ObjectSerializer.deserialize(jsonBody, "Array<Pet>") as Array<Pet>;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -392,7 +403,8 @@ export class PetApiResponseProcessor {
|
|||||||
const body: Array<Pet> = ObjectSerializer.deserialize(jsonBody, "Array<Pet>") as Array<Pet>;
|
const body: Array<Pet> = ObjectSerializer.deserialize(jsonBody, "Array<Pet>") as Array<Pet>;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -418,7 +430,8 @@ export class PetApiResponseProcessor {
|
|||||||
const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet;
|
const body: Pet = ObjectSerializer.deserialize(jsonBody, "Pet") as Pet;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,7 +453,8 @@ export class PetApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -456,7 +470,8 @@ export class PetApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -476,7 +491,8 @@ export class PetApiResponseProcessor {
|
|||||||
const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse;
|
const body: ApiResponse = ObjectSerializer.deserialize(jsonBody, "ApiResponse") as ApiResponse;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -46,7 +47,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -79,7 +81,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -106,7 +109,8 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -150,7 +154,8 @@ export class StoreApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,7 +175,8 @@ export class StoreApiResponseProcessor {
|
|||||||
const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; };
|
const body: { [key: string]: number; } = ObjectSerializer.deserialize(jsonBody, "{ [key: string]: number; }") as { [key: string]: number; };
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,7 +202,8 @@ export class StoreApiResponseProcessor {
|
|||||||
const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order;
|
const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +226,8 @@ export class StoreApiResponseProcessor {
|
|||||||
const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order;
|
const body: Order = ObjectSerializer.deserialize(jsonBody, "Order") as Order;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -55,7 +56,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -87,7 +89,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -120,7 +123,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -148,7 +152,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -180,13 +185,14 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
if (username !== undefined) {
|
if (username !== undefined) {
|
||||||
requestContext.setQueryParam("", ObjectSerializer.serialize(username, "string"));
|
requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string"));
|
||||||
}
|
}
|
||||||
if (password !== undefined) {
|
if (password !== undefined) {
|
||||||
requestContext.setQueryParam("", ObjectSerializer.serialize(password, "string"));
|
requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -208,7 +214,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -241,7 +248,8 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
|||||||
|
|
||||||
// Make Request Context
|
// Make Request Context
|
||||||
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
|
const requestContext = this.configuration.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json")
|
||||||
|
|
||||||
// Query Params
|
// Query Params
|
||||||
|
|
||||||
// Header Params
|
// Header Params
|
||||||
@ -282,7 +290,8 @@ export class UserApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -298,7 +307,8 @@ export class UserApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,7 +324,8 @@ export class UserApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -333,7 +344,8 @@ export class UserApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -359,7 +371,8 @@ export class UserApiResponseProcessor {
|
|||||||
const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User;
|
const body: User = ObjectSerializer.deserialize(jsonBody, "User") as User;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -382,7 +395,8 @@ export class UserApiResponseProcessor {
|
|||||||
const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string;
|
const body: string = ObjectSerializer.deserialize(jsonBody, "string") as string;
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -398,7 +412,8 @@ export class UserApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -417,7 +432,8 @@ export class UserApiResponseProcessor {
|
|||||||
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!");
|
let body = response.body || "";
|
||||||
|
throw new ApiException<string>(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export class ApiException<T> extends Error {
|
export class ApiException<T> extends Error {
|
||||||
public constructor(public code: number, public body: T) {
|
public constructor(public code: number, public body: T) {
|
||||||
super("Got HTTP Status Code " + code)
|
super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,19 @@
|
|||||||
import {PetApi, Configuration, Pet, ApiException} from 'ts-petstore-client'
|
import {PetApi, Configuration, Pet, ApiException, Tag} from 'ts-petstore-client'
|
||||||
import { expect, assert } from "chai";
|
import { expect, assert } from "chai";
|
||||||
|
|
||||||
const configuration = new Configuration()
|
const configuration = new Configuration()
|
||||||
const petApi = new PetApi(configuration)
|
const petApi = new PetApi(configuration)
|
||||||
|
|
||||||
|
const tag = new Tag();
|
||||||
|
tag.name = "tag1"
|
||||||
|
tag.id = Math.floor(Math.random() * 100000)
|
||||||
|
|
||||||
const pet = new Pet()
|
const pet = new Pet()
|
||||||
pet.id = Math.floor(Math.random() * 100000)
|
pet.id = Math.floor(Math.random() * 100000)
|
||||||
pet.name = "PetName"
|
pet.name = "PetName"
|
||||||
pet.photoUrls = []
|
pet.photoUrls = []
|
||||||
pet.status = Pet.StatusEnum.Available
|
pet.status = Pet.StatusEnum.Available
|
||||||
pet.tags = []
|
pet.tags = [ tag ]
|
||||||
pet.category = undefined
|
pet.category = undefined
|
||||||
|
|
||||||
describe("PetApi", () =>{
|
describe("PetApi", () =>{
|
||||||
@ -41,4 +45,81 @@ describe("PetApi", () =>{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("findPetsByStatus", (done) => {
|
||||||
|
petApi.addPet(pet).then(() => {
|
||||||
|
return petApi.findPetsByStatus(["available"])
|
||||||
|
}).then((pets: Pet[]) => {
|
||||||
|
expect(pets.length).to.be.at.least(1);
|
||||||
|
done();
|
||||||
|
}).catch((err) => {
|
||||||
|
done(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// bugged on server side! Code 500
|
||||||
|
/* it("findPetsByTag", (done) => {
|
||||||
|
petApi.addPet(pet).then(() => {
|
||||||
|
return petApi.findPetsByTags([tag.name])
|
||||||
|
}).then((pets: Pet[]) => {
|
||||||
|
expect(pets.length).to.be.at.least(1);
|
||||||
|
done();
|
||||||
|
}).catch((err) => {
|
||||||
|
done(err);
|
||||||
|
})
|
||||||
|
})*/
|
||||||
|
|
||||||
|
it("getPetById", (done) => {
|
||||||
|
petApi.addPet(pet).then(() => {
|
||||||
|
return petApi.getPetById(pet.id)
|
||||||
|
}).then((returnedPet: Pet) => {
|
||||||
|
expect(returnedPet).to.deep.equal(pet);
|
||||||
|
done();
|
||||||
|
}).catch((err) => {
|
||||||
|
done(err);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("updatePet", (done) => {
|
||||||
|
const oldName = pet.name
|
||||||
|
const updatedName = "updated name";
|
||||||
|
petApi.addPet(pet).then(() => {
|
||||||
|
pet.name = updatedName
|
||||||
|
return petApi.updatePet(pet).then(() => {
|
||||||
|
pet.name = oldName;
|
||||||
|
}).catch((err) => {
|
||||||
|
pet.name = oldName
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
}).then(() => {
|
||||||
|
return petApi.getPetById(pet.id);
|
||||||
|
}).then((returnedPet: Pet) => {
|
||||||
|
expect(returnedPet.id).to.equal(pet.id)
|
||||||
|
expect(returnedPet.name).to.equal(updatedName);
|
||||||
|
done();
|
||||||
|
}).catch((err) => {
|
||||||
|
done(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// not supported by online swagger api?
|
||||||
|
/* it("updatePetWithForm", (done) => {
|
||||||
|
const updatedName = "updated name";
|
||||||
|
petApi.addPet(pet).then(() => {
|
||||||
|
return petApi.updatePetWithForm(pet.id, updatedName)
|
||||||
|
}).then(() => {
|
||||||
|
return petApi.getPetById(pet.id)
|
||||||
|
}).then((returnedPet: Pet) => {
|
||||||
|
expect(returnedPet.id).to.equal(pet.id)
|
||||||
|
expect(returnedPet.name).to.equal(updatedName);
|
||||||
|
done()
|
||||||
|
}).catch((err) => {
|
||||||
|
done(err)
|
||||||
|
})
|
||||||
|
})*/
|
||||||
|
|
||||||
|
/* it("", (done) => {
|
||||||
|
file
|
||||||
|
petApi.uploadFile(pet.id, "", file)
|
||||||
|
})*/
|
||||||
})
|
})
|
Loading…
x
Reference in New Issue
Block a user