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 @@ -41,7 +41,7 @@ export class {{classname}} extends BaseAPI {
{{#hasParams}}
{{#allParams}}
{{#required}}
throwIfNullOrUndefined({{> paramNamePartial}}, '{{nickname}}');
throwIfNullOrUndefined({{> paramNamePartial}}, '{{> paramNamePartial}}', '{{nickname}}');
{{/required}}
{{/allParams}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class PetApi extends BaseAPI {
* Add a new pet to the store
*/
addPet = ({ body }: AddPetRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'addPet');
throwIfNullOrUndefined(body, 'body', 'addPet');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -89,7 +89,7 @@ export class PetApi extends BaseAPI {
* Deletes a pet
*/
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
throwIfNullOrUndefined(petId, 'deletePet');
throwIfNullOrUndefined(petId, 'petId', 'deletePet');

const headers: HttpHeaders = {
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
Expand All @@ -114,7 +114,7 @@ export class PetApi extends BaseAPI {
* Finds Pets by status
*/
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
throwIfNullOrUndefined(status, 'findPetsByStatus');
throwIfNullOrUndefined(status, 'status', 'findPetsByStatus');

const headers: HttpHeaders = {
// oauth required
Expand Down Expand Up @@ -143,7 +143,7 @@ export class PetApi extends BaseAPI {
* Finds Pets by tags
*/
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
throwIfNullOrUndefined(tags, 'findPetsByTags');
throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags');

const headers: HttpHeaders = {
// oauth required
Expand Down Expand Up @@ -172,7 +172,7 @@ export class PetApi extends BaseAPI {
* Find pet by ID
*/
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
throwIfNullOrUndefined(petId, 'getPetById');
throwIfNullOrUndefined(petId, 'petId', 'getPetById');

const headers: HttpHeaders = {
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
Expand All @@ -189,7 +189,7 @@ export class PetApi extends BaseAPI {
* Update an existing pet
*/
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'updatePet');
throwIfNullOrUndefined(body, 'body', 'updatePet');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -214,7 +214,7 @@ export class PetApi extends BaseAPI {
* Updates a pet in the store with form data
*/
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
throwIfNullOrUndefined(petId, 'updatePetWithForm');
throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm');

const headers: HttpHeaders = {
// oauth required
Expand Down Expand Up @@ -242,7 +242,7 @@ export class PetApi extends BaseAPI {
* uploads an image
*/
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
throwIfNullOrUndefined(petId, 'uploadFile');
throwIfNullOrUndefined(petId, 'petId', 'uploadFile');

const headers: HttpHeaders = {
// oauth required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class StoreApi extends BaseAPI {
* Delete purchase order by ID
*/
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
throwIfNullOrUndefined(orderId, 'deleteOrder');
throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder');

return this.request<void>({
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
Expand Down Expand Up @@ -68,7 +68,7 @@ export class StoreApi extends BaseAPI {
* Find purchase order by ID
*/
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
throwIfNullOrUndefined(orderId, 'getOrderById');
throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById');

return this.request<Order>({
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
Expand All @@ -80,7 +80,7 @@ export class StoreApi extends BaseAPI {
* Place an order for a pet
*/
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
throwIfNullOrUndefined(body, 'placeOrder');
throwIfNullOrUndefined(body, 'body', 'placeOrder');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UserApi extends BaseAPI {
* Create user
*/
createUser = ({ body }: CreateUserRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'createUser');
throwIfNullOrUndefined(body, 'body', 'createUser');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -75,7 +75,7 @@ export class UserApi extends BaseAPI {
* Creates list of users with given input array
*/
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'createUsersWithArrayInput');
throwIfNullOrUndefined(body, 'body', 'createUsersWithArrayInput');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -93,7 +93,7 @@ export class UserApi extends BaseAPI {
* Creates list of users with given input array
*/
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'createUsersWithListInput');
throwIfNullOrUndefined(body, 'body', 'createUsersWithListInput');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -112,7 +112,7 @@ export class UserApi extends BaseAPI {
* Delete user
*/
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
throwIfNullOrUndefined(username, 'deleteUser');
throwIfNullOrUndefined(username, 'username', 'deleteUser');

return this.request<void>({
path: '/user/{username}'.replace('{username}', encodeURI(username)),
Expand All @@ -124,7 +124,7 @@ export class UserApi extends BaseAPI {
* Get user by user name
*/
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
throwIfNullOrUndefined(username, 'getUserByName');
throwIfNullOrUndefined(username, 'username', 'getUserByName');

return this.request<User>({
path: '/user/{username}'.replace('{username}', encodeURI(username)),
Expand All @@ -136,8 +136,8 @@ export class UserApi extends BaseAPI {
* Logs user into the system
*/
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
throwIfNullOrUndefined(username, 'loginUser');
throwIfNullOrUndefined(password, 'loginUser');
throwIfNullOrUndefined(username, 'username', 'loginUser');
throwIfNullOrUndefined(password, 'password', 'loginUser');

const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
'username': username,
Expand Down Expand Up @@ -166,8 +166,8 @@ export class UserApi extends BaseAPI {
* Updated user
*/
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
throwIfNullOrUndefined(username, 'updateUser');
throwIfNullOrUndefined(body, 'updateUser');
throwIfNullOrUndefined(username, 'username', 'updateUser');
throwIfNullOrUndefined(body, 'body', 'updateUser');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class PetApi extends BaseAPI {
* Add a new pet to the store
*/
addPet = ({ body }: AddPetRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'addPet');
throwIfNullOrUndefined(body, 'body', 'addPet');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -89,7 +89,7 @@ export class PetApi extends BaseAPI {
* Deletes a pet
*/
deletePet = ({ petId, apiKey }: DeletePetRequest): Observable<void> => {
throwIfNullOrUndefined(petId, 'deletePet');
throwIfNullOrUndefined(petId, 'petId', 'deletePet');

const headers: HttpHeaders = {
...(apiKey != null ? { 'api_key': String(apiKey) } : undefined),
Expand All @@ -114,7 +114,7 @@ export class PetApi extends BaseAPI {
* Finds Pets by status
*/
findPetsByStatus = ({ status }: FindPetsByStatusRequest): Observable<Array<Pet>> => {
throwIfNullOrUndefined(status, 'findPetsByStatus');
throwIfNullOrUndefined(status, 'status', 'findPetsByStatus');

const headers: HttpHeaders = {
// oauth required
Expand Down Expand Up @@ -143,7 +143,7 @@ export class PetApi extends BaseAPI {
* Finds Pets by tags
*/
findPetsByTags = ({ tags }: FindPetsByTagsRequest): Observable<Array<Pet>> => {
throwIfNullOrUndefined(tags, 'findPetsByTags');
throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags');

const headers: HttpHeaders = {
// oauth required
Expand Down Expand Up @@ -172,7 +172,7 @@ export class PetApi extends BaseAPI {
* Find pet by ID
*/
getPetById = ({ petId }: GetPetByIdRequest): Observable<Pet> => {
throwIfNullOrUndefined(petId, 'getPetById');
throwIfNullOrUndefined(petId, 'petId', 'getPetById');

const headers: HttpHeaders = {
...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication
Expand All @@ -189,7 +189,7 @@ export class PetApi extends BaseAPI {
* Update an existing pet
*/
updatePet = ({ body }: UpdatePetRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'updatePet');
throwIfNullOrUndefined(body, 'body', 'updatePet');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -214,7 +214,7 @@ export class PetApi extends BaseAPI {
* Updates a pet in the store with form data
*/
updatePetWithForm = ({ petId, name, status }: UpdatePetWithFormRequest): Observable<void> => {
throwIfNullOrUndefined(petId, 'updatePetWithForm');
throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm');

const headers: HttpHeaders = {
// oauth required
Expand Down Expand Up @@ -242,7 +242,7 @@ export class PetApi extends BaseAPI {
* uploads an image
*/
uploadFile = ({ petId, additionalMetadata, file }: UploadFileRequest): Observable<ApiResponse> => {
throwIfNullOrUndefined(petId, 'uploadFile');
throwIfNullOrUndefined(petId, 'petId', 'uploadFile');

const headers: HttpHeaders = {
// oauth required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class StoreApi extends BaseAPI {
* Delete purchase order by ID
*/
deleteOrder = ({ orderId }: DeleteOrderRequest): Observable<void> => {
throwIfNullOrUndefined(orderId, 'deleteOrder');
throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder');

return this.request<void>({
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
Expand Down Expand Up @@ -68,7 +68,7 @@ export class StoreApi extends BaseAPI {
* Find purchase order by ID
*/
getOrderById = ({ orderId }: GetOrderByIdRequest): Observable<Order> => {
throwIfNullOrUndefined(orderId, 'getOrderById');
throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById');

return this.request<Order>({
path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)),
Expand All @@ -80,7 +80,7 @@ export class StoreApi extends BaseAPI {
* Place an order for a pet
*/
placeOrder = ({ body }: PlaceOrderRequest): Observable<Order> => {
throwIfNullOrUndefined(body, 'placeOrder');
throwIfNullOrUndefined(body, 'body', 'placeOrder');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UserApi extends BaseAPI {
* Create user
*/
createUser = ({ body }: CreateUserRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'createUser');
throwIfNullOrUndefined(body, 'body', 'createUser');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -75,7 +75,7 @@ export class UserApi extends BaseAPI {
* Creates list of users with given input array
*/
createUsersWithArrayInput = ({ body }: CreateUsersWithArrayInputRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'createUsersWithArrayInput');
throwIfNullOrUndefined(body, 'body', 'createUsersWithArrayInput');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -93,7 +93,7 @@ export class UserApi extends BaseAPI {
* Creates list of users with given input array
*/
createUsersWithListInput = ({ body }: CreateUsersWithListInputRequest): Observable<void> => {
throwIfNullOrUndefined(body, 'createUsersWithListInput');
throwIfNullOrUndefined(body, 'body', 'createUsersWithListInput');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand All @@ -112,7 +112,7 @@ export class UserApi extends BaseAPI {
* Delete user
*/
deleteUser = ({ username }: DeleteUserRequest): Observable<void> => {
throwIfNullOrUndefined(username, 'deleteUser');
throwIfNullOrUndefined(username, 'username', 'deleteUser');

return this.request<void>({
path: '/user/{username}'.replace('{username}', encodeURI(username)),
Expand All @@ -124,7 +124,7 @@ export class UserApi extends BaseAPI {
* Get user by user name
*/
getUserByName = ({ username }: GetUserByNameRequest): Observable<User> => {
throwIfNullOrUndefined(username, 'getUserByName');
throwIfNullOrUndefined(username, 'username', 'getUserByName');

return this.request<User>({
path: '/user/{username}'.replace('{username}', encodeURI(username)),
Expand All @@ -136,8 +136,8 @@ export class UserApi extends BaseAPI {
* Logs user into the system
*/
loginUser = ({ username, password }: LoginUserRequest): Observable<string> => {
throwIfNullOrUndefined(username, 'loginUser');
throwIfNullOrUndefined(password, 'loginUser');
throwIfNullOrUndefined(username, 'username', 'loginUser');
throwIfNullOrUndefined(password, 'password', 'loginUser');

const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined
'username': username,
Expand Down Expand Up @@ -166,8 +166,8 @@ export class UserApi extends BaseAPI {
* Updated user
*/
updateUser = ({ username, body }: UpdateUserRequest): Observable<void> => {
throwIfNullOrUndefined(username, 'updateUser');
throwIfNullOrUndefined(body, 'updateUser');
throwIfNullOrUndefined(username, 'username', 'updateUser');
throwIfNullOrUndefined(body, 'body', 'updateUser');

const headers: HttpHeaders = {
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
throw new Error(`Parameter "${value}" was null or undefined when calling "${nickname}".`);
throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`);
}
};

Expand Down
Loading