forked from loafle/openapi-generator-original
Typescript-rxjs: print param name (#6368)
* Prints out the parameter name in throwIfNullOrUndefined * Fixed misspelling Co-authored-by: Justin Van Dort <justinvandort@gmail.com> Co-authored-by: Esteban Gehring <esteban.gehring@bithost.ch>
This commit is contained in:
parent
66a3ec7cf0
commit
8fc7ec8458
@ -41,7 +41,7 @@ export class {{classname}} extends BaseAPI {
|
|||||||
{{#hasParams}}
|
{{#hasParams}}
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
throwIfNullOrUndefined({{> paramNamePartial}}, '{{nickname}}');
|
throwIfNullOrUndefined({{> paramNamePartial}}, '{{> paramNamePartial}}', '{{nickname}}');
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
|
@ -178,9 +178,9 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const throwIfNullOrUndefined = (value: any, nickname?: string) => {
|
export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
|
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*/
|
*/
|
||||||
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'addPet');
|
throwIfNullOrUndefined(body, 'body', 'addPet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -89,7 +89,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*/
|
*/
|
||||||
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'deletePet');
|
throwIfNullOrUndefined(petId, 'petId', 'deletePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
||||||
@ -114,7 +114,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
*/
|
*/
|
||||||
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(status, 'findPetsByStatus');
|
throwIfNullOrUndefined(status, 'status', 'findPetsByStatus');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -143,7 +143,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
*/
|
*/
|
||||||
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(tags, 'findPetsByTags');
|
throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -172,7 +172,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
*/
|
*/
|
||||||
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
||||||
throwIfNullOrUndefined(petId, 'getPetById');
|
throwIfNullOrUndefined(petId, 'petId', 'getPetById');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
||||||
@ -189,7 +189,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*/
|
*/
|
||||||
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'updatePet');
|
throwIfNullOrUndefined(body, 'body', 'updatePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -214,7 +214,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
*/
|
*/
|
||||||
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'updatePetWithForm');
|
throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -242,7 +242,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* uploads an image
|
* uploads an image
|
||||||
*/
|
*/
|
||||||
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
||||||
throwIfNullOrUndefined(petId, 'uploadFile');
|
throwIfNullOrUndefined(petId, 'petId', 'uploadFile');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
|
@ -39,7 +39,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
*/
|
*/
|
||||||
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(orderId, 'deleteOrder');
|
throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -68,7 +68,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
*/
|
*/
|
||||||
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(orderId, 'getOrderById');
|
throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById');
|
||||||
|
|
||||||
return this.request<Order>({
|
return this.request<Order>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -80,7 +80,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
*/
|
*/
|
||||||
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(body, 'placeOrder');
|
throwIfNullOrUndefined(body, 'body', 'placeOrder');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -57,7 +57,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Create user
|
* Create user
|
||||||
*/
|
*/
|
||||||
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUser');
|
throwIfNullOrUndefined(body, 'body', 'createUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -75,7 +75,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithArrayInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithArrayInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -93,7 +93,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithListInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithListInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -112,7 +112,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Delete user
|
* Delete user
|
||||||
*/
|
*/
|
||||||
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'deleteUser');
|
throwIfNullOrUndefined(username, 'username', 'deleteUser');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -124,7 +124,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Get user by user name
|
* Get user by user name
|
||||||
*/
|
*/
|
||||||
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
||||||
throwIfNullOrUndefined(username, 'getUserByName');
|
throwIfNullOrUndefined(username, 'username', 'getUserByName');
|
||||||
|
|
||||||
return this.request<User>({
|
return this.request<User>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -136,8 +136,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
*/
|
*/
|
||||||
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
||||||
throwIfNullOrUndefined(username, 'loginUser');
|
throwIfNullOrUndefined(username, 'username', 'loginUser');
|
||||||
throwIfNullOrUndefined(password, 'loginUser');
|
throwIfNullOrUndefined(password, 'password', 'loginUser');
|
||||||
|
|
||||||
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
||||||
'username': username,
|
'username': username,
|
||||||
@ -166,8 +166,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Updated user
|
* Updated user
|
||||||
*/
|
*/
|
||||||
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'updateUser');
|
throwIfNullOrUndefined(username, 'username', 'updateUser');
|
||||||
throwIfNullOrUndefined(body, 'updateUser');
|
throwIfNullOrUndefined(body, 'body', 'updateUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -189,9 +189,9 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const throwIfNullOrUndefined = (value: any, nickname?: string) => {
|
export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
|
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*/
|
*/
|
||||||
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'addPet');
|
throwIfNullOrUndefined(body, 'body', 'addPet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -89,7 +89,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*/
|
*/
|
||||||
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'deletePet');
|
throwIfNullOrUndefined(petId, 'petId', 'deletePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
||||||
@ -114,7 +114,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
*/
|
*/
|
||||||
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(status, 'findPetsByStatus');
|
throwIfNullOrUndefined(status, 'status', 'findPetsByStatus');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -143,7 +143,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
*/
|
*/
|
||||||
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(tags, 'findPetsByTags');
|
throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -172,7 +172,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
*/
|
*/
|
||||||
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
||||||
throwIfNullOrUndefined(petId, 'getPetById');
|
throwIfNullOrUndefined(petId, 'petId', 'getPetById');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
||||||
@ -189,7 +189,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*/
|
*/
|
||||||
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'updatePet');
|
throwIfNullOrUndefined(body, 'body', 'updatePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -214,7 +214,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
*/
|
*/
|
||||||
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'updatePetWithForm');
|
throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -242,7 +242,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* uploads an image
|
* uploads an image
|
||||||
*/
|
*/
|
||||||
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
||||||
throwIfNullOrUndefined(petId, 'uploadFile');
|
throwIfNullOrUndefined(petId, 'petId', 'uploadFile');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
|
@ -39,7 +39,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
*/
|
*/
|
||||||
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(orderId, 'deleteOrder');
|
throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -68,7 +68,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
*/
|
*/
|
||||||
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(orderId, 'getOrderById');
|
throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById');
|
||||||
|
|
||||||
return this.request<Order>({
|
return this.request<Order>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -80,7 +80,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
*/
|
*/
|
||||||
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(body, 'placeOrder');
|
throwIfNullOrUndefined(body, 'body', 'placeOrder');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -57,7 +57,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Create user
|
* Create user
|
||||||
*/
|
*/
|
||||||
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUser');
|
throwIfNullOrUndefined(body, 'body', 'createUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -75,7 +75,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithArrayInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithArrayInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -93,7 +93,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithListInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithListInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -112,7 +112,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Delete user
|
* Delete user
|
||||||
*/
|
*/
|
||||||
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'deleteUser');
|
throwIfNullOrUndefined(username, 'username', 'deleteUser');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -124,7 +124,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Get user by user name
|
* Get user by user name
|
||||||
*/
|
*/
|
||||||
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
||||||
throwIfNullOrUndefined(username, 'getUserByName');
|
throwIfNullOrUndefined(username, 'username', 'getUserByName');
|
||||||
|
|
||||||
return this.request<User>({
|
return this.request<User>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -136,8 +136,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
*/
|
*/
|
||||||
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
||||||
throwIfNullOrUndefined(username, 'loginUser');
|
throwIfNullOrUndefined(username, 'username', 'loginUser');
|
||||||
throwIfNullOrUndefined(password, 'loginUser');
|
throwIfNullOrUndefined(password, 'password', 'loginUser');
|
||||||
|
|
||||||
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
||||||
'username': username,
|
'username': username,
|
||||||
@ -166,8 +166,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Updated user
|
* Updated user
|
||||||
*/
|
*/
|
||||||
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'updateUser');
|
throwIfNullOrUndefined(username, 'username', 'updateUser');
|
||||||
throwIfNullOrUndefined(body, 'updateUser');
|
throwIfNullOrUndefined(body, 'body', 'updateUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -189,9 +189,9 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const throwIfNullOrUndefined = (value: any, nickname?: string) => {
|
export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
|
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*/
|
*/
|
||||||
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'addPet');
|
throwIfNullOrUndefined(body, 'body', 'addPet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -89,7 +89,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*/
|
*/
|
||||||
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'deletePet');
|
throwIfNullOrUndefined(petId, 'petId', 'deletePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
||||||
@ -114,7 +114,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
*/
|
*/
|
||||||
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(status, 'findPetsByStatus');
|
throwIfNullOrUndefined(status, 'status', 'findPetsByStatus');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -143,7 +143,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
*/
|
*/
|
||||||
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(tags, 'findPetsByTags');
|
throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -172,7 +172,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
*/
|
*/
|
||||||
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
||||||
throwIfNullOrUndefined(petId, 'getPetById');
|
throwIfNullOrUndefined(petId, 'petId', 'getPetById');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
||||||
@ -189,7 +189,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*/
|
*/
|
||||||
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'updatePet');
|
throwIfNullOrUndefined(body, 'body', 'updatePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -214,7 +214,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
*/
|
*/
|
||||||
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'updatePetWithForm');
|
throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -242,7 +242,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* uploads an image
|
* uploads an image
|
||||||
*/
|
*/
|
||||||
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
||||||
throwIfNullOrUndefined(petId, 'uploadFile');
|
throwIfNullOrUndefined(petId, 'petId', 'uploadFile');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
|
@ -39,7 +39,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
*/
|
*/
|
||||||
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(orderId, 'deleteOrder');
|
throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -68,7 +68,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
*/
|
*/
|
||||||
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(orderId, 'getOrderById');
|
throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById');
|
||||||
|
|
||||||
return this.request<Order>({
|
return this.request<Order>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -80,7 +80,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
*/
|
*/
|
||||||
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(body, 'placeOrder');
|
throwIfNullOrUndefined(body, 'body', 'placeOrder');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -57,7 +57,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Create user
|
* Create user
|
||||||
*/
|
*/
|
||||||
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUser');
|
throwIfNullOrUndefined(body, 'body', 'createUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -75,7 +75,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithArrayInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithArrayInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -93,7 +93,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithListInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithListInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -112,7 +112,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Delete user
|
* Delete user
|
||||||
*/
|
*/
|
||||||
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'deleteUser');
|
throwIfNullOrUndefined(username, 'username', 'deleteUser');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -124,7 +124,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Get user by user name
|
* Get user by user name
|
||||||
*/
|
*/
|
||||||
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
||||||
throwIfNullOrUndefined(username, 'getUserByName');
|
throwIfNullOrUndefined(username, 'username', 'getUserByName');
|
||||||
|
|
||||||
return this.request<User>({
|
return this.request<User>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -136,8 +136,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
*/
|
*/
|
||||||
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
||||||
throwIfNullOrUndefined(username, 'loginUser');
|
throwIfNullOrUndefined(username, 'username', 'loginUser');
|
||||||
throwIfNullOrUndefined(password, 'loginUser');
|
throwIfNullOrUndefined(password, 'password', 'loginUser');
|
||||||
|
|
||||||
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
||||||
'username': username,
|
'username': username,
|
||||||
@ -166,8 +166,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Updated user
|
* Updated user
|
||||||
*/
|
*/
|
||||||
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'updateUser');
|
throwIfNullOrUndefined(username, 'username', 'updateUser');
|
||||||
throwIfNullOrUndefined(body, 'updateUser');
|
throwIfNullOrUndefined(body, 'body', 'updateUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -189,9 +189,9 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const throwIfNullOrUndefined = (value: any, nickname?: string) => {
|
export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
|
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*/
|
*/
|
||||||
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
addPet = ({ body }: AddPetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'addPet');
|
throwIfNullOrUndefined(body, 'body', 'addPet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -89,7 +89,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*/
|
*/
|
||||||
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'deletePet');
|
throwIfNullOrUndefined(petId, 'petId', 'deletePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
|
||||||
@ -114,7 +114,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
*/
|
*/
|
||||||
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(status, 'findPetsByStatus');
|
throwIfNullOrUndefined(status, 'status', 'findPetsByStatus');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -143,7 +143,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
*/
|
*/
|
||||||
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
|
||||||
throwIfNullOrUndefined(tags, 'findPetsByTags');
|
throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -172,7 +172,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
*/
|
*/
|
||||||
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
|
||||||
throwIfNullOrUndefined(petId, 'getPetById');
|
throwIfNullOrUndefined(petId, 'petId', 'getPetById');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
|
||||||
@ -189,7 +189,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*/
|
*/
|
||||||
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'updatePet');
|
throwIfNullOrUndefined(body, 'body', 'updatePet');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -214,7 +214,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
*/
|
*/
|
||||||
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(petId, 'updatePetWithForm');
|
throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
@ -242,7 +242,7 @@ export class PetApi extends BaseAPI {
|
|||||||
* uploads an image
|
* uploads an image
|
||||||
*/
|
*/
|
||||||
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
|
||||||
throwIfNullOrUndefined(petId, 'uploadFile');
|
throwIfNullOrUndefined(petId, 'petId', 'uploadFile');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
// oauth required
|
// oauth required
|
||||||
|
@ -39,7 +39,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
*/
|
*/
|
||||||
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(orderId, 'deleteOrder');
|
throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -68,7 +68,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
*/
|
*/
|
||||||
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(orderId, 'getOrderById');
|
throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById');
|
||||||
|
|
||||||
return this.request<Order>({
|
return this.request<Order>({
|
||||||
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
|
||||||
@ -80,7 +80,7 @@ export class StoreApi extends BaseAPI {
|
|||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
*/
|
*/
|
||||||
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
|
||||||
throwIfNullOrUndefined(body, 'placeOrder');
|
throwIfNullOrUndefined(body, 'body', 'placeOrder');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -57,7 +57,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Create user
|
* Create user
|
||||||
*/
|
*/
|
||||||
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
createUser = ({ body }: CreateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUser');
|
throwIfNullOrUndefined(body, 'body', 'createUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -75,7 +75,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithArrayInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithArrayInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -93,7 +93,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*/
|
*/
|
||||||
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(body, 'createUsersWithListInput');
|
throwIfNullOrUndefined(body, 'body', 'createUsersWithListInput');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -112,7 +112,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Delete user
|
* Delete user
|
||||||
*/
|
*/
|
||||||
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'deleteUser');
|
throwIfNullOrUndefined(username, 'username', 'deleteUser');
|
||||||
|
|
||||||
return this.request<void>({
|
return this.request<void>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -124,7 +124,7 @@ export class UserApi extends BaseAPI {
|
|||||||
* Get user by user name
|
* Get user by user name
|
||||||
*/
|
*/
|
||||||
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
|
||||||
throwIfNullOrUndefined(username, 'getUserByName');
|
throwIfNullOrUndefined(username, 'username', 'getUserByName');
|
||||||
|
|
||||||
return this.request<User>({
|
return this.request<User>({
|
||||||
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
path: '/user/{username}'.replace('{username}', encodeURI(username)),
|
||||||
@ -136,8 +136,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
*/
|
*/
|
||||||
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
|
||||||
throwIfNullOrUndefined(username, 'loginUser');
|
throwIfNullOrUndefined(username, 'username', 'loginUser');
|
||||||
throwIfNullOrUndefined(password, 'loginUser');
|
throwIfNullOrUndefined(password, 'password', 'loginUser');
|
||||||
|
|
||||||
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
|
||||||
'username': username,
|
'username': username,
|
||||||
@ -166,8 +166,8 @@ export class UserApi extends BaseAPI {
|
|||||||
* Updated user
|
* Updated user
|
||||||
*/
|
*/
|
||||||
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
|
||||||
throwIfNullOrUndefined(username, 'updateUser');
|
throwIfNullOrUndefined(username, 'username', 'updateUser');
|
||||||
throwIfNullOrUndefined(body, 'updateUser');
|
throwIfNullOrUndefined(body, 'body', 'updateUser');
|
||||||
|
|
||||||
const headers: HttpHeaders = {
|
const headers: HttpHeaders = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -189,9 +189,9 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const throwIfNullOrUndefined = (value: any, nickname?: string) => {
|
export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
|
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user