Fixed required parameters for APIs in TypeScript

This commit is contained in:
Martin Hardorf 2015-06-18 12:42:04 +02:00
parent e7d4a438dd
commit 449ba4f644
8 changed files with 100 additions and 10 deletions

View File

@ -29,12 +29,12 @@ module {{package}} {
{{/pathParams}}
var queryParameters: any = {};
var headers: any = {};
{{#requiredParamCount}}
// verify required params are set
if ({{/requiredParamCount}}{{#requiredParams}} !{{paramName}} {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
throw new Error('Missing required parameter: {{&paramName}}');
{{#allParams}}{{#required}}
// verify required parameter '{{paramName}}' is set
if (!{{paramName}}) {
throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}');
}
{{/requiredParamCount}}
{{/required}}{{/allParams}}
{{#queryParams}}if ({{paramName}} !== undefined) {
queryParameters['{{paramName}}'] = {{paramName}};
}{{/queryParams}}

View File

@ -26,12 +26,12 @@ export class {{classname}} {
var queryParameters: any = {};
var headers: any = {};
{{#requiredParamCount}}
// verify required params are set
if ({{/requiredParamCount}}{{#requiredParams}} !{{paramName}} {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
throw new Error('Missing required parameter: {{&paramName}}');
{{#allParams}}{{#required}}
// verify required parameter '{{paramName}}' is set
if (!{{paramName}}) {
throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}');
}
{{/requiredParamCount}}
{{/required}}{{/allParams}}
{{#queryParams}}if ({{paramName}} !== undefined) {
queryParameters['{{paramName}}'] = {{paramName}};

View File

@ -143,6 +143,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling getPetById');
}
var httpRequestParams: any = {
@ -173,6 +178,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling updatePetWithForm');
}
var httpRequestParams: any = {
@ -203,6 +213,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling deletePet');
}
headerParams['apiKey'] = apiKey;
var httpRequestParams: any = {
@ -233,6 +248,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling uploadFile');
}
var httpRequestParams: any = {

View File

@ -82,6 +82,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'orderId' is set
if (!orderId) {
throw new Error('Missing required parameter orderId when calling getOrderById');
}
var httpRequestParams: any = {
@ -112,6 +117,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'orderId' is set
if (!orderId) {
throw new Error('Missing required parameter orderId when calling deleteOrder');
}
var httpRequestParams: any = {

View File

@ -172,6 +172,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'username' is set
if (!username) {
throw new Error('Missing required parameter username when calling getUserByName');
}
var httpRequestParams: any = {
@ -202,6 +207,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'username' is set
if (!username) {
throw new Error('Missing required parameter username when calling updateUser');
}
var httpRequestParams: any = {
@ -233,6 +243,11 @@ module api {
var queryParameters: any = {};
var headers: any = {};
// verify required parameter 'username' is set
if (!username) {
throw new Error('Missing required parameter username when calling deleteUser');
}
var httpRequestParams: any = {

View File

@ -193,6 +193,11 @@ export class PetApi {
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling getPetById');
}
@ -236,6 +241,11 @@ export class PetApi {
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling updatePetWithForm');
}
@ -279,6 +289,11 @@ export class PetApi {
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling deletePet');
}
@ -323,6 +338,11 @@ export class PetApi {
var headers: any = {};
// verify required parameter 'petId' is set
if (!petId) {
throw new Error('Missing required parameter petId when calling uploadFile');
}

View File

@ -104,6 +104,11 @@ export class StoreApi {
var headers: any = {};
// verify required parameter 'orderId' is set
if (!orderId) {
throw new Error('Missing required parameter orderId when calling getOrderById');
}
@ -147,6 +152,11 @@ export class StoreApi {
var headers: any = {};
// verify required parameter 'orderId' is set
if (!orderId) {
throw new Error('Missing required parameter orderId when calling deleteOrder');
}

View File

@ -235,6 +235,11 @@ export class UserApi {
var headers: any = {};
// verify required parameter 'username' is set
if (!username) {
throw new Error('Missing required parameter username when calling getUserByName');
}
@ -278,6 +283,11 @@ export class UserApi {
var headers: any = {};
// verify required parameter 'username' is set
if (!username) {
throw new Error('Missing required parameter username when calling updateUser');
}
@ -322,6 +332,11 @@ export class UserApi {
var headers: any = {};
// verify required parameter 'username' is set
if (!username) {
throw new Error('Missing required parameter username when calling deleteUser');
}