Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript][Angular] fix issues with empty body #6754

Merged
merged 8 commits into from
Oct 24, 2017
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 @@ -140,6 +140,15 @@ public boolean isRestfulUpdate() {
return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isMemberPath();
}

/**
* Check if body param is allowed for the request method
*
* @return true request method is PUT, PATCH or POST; false otherwise
*/
public boolean isBodyAllowed() {
return Arrays.asList("PUT", "PATCH", "POST").contains(httpMethod.toUpperCase());
}

/**
* Check if act as Restful destroy method
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,19 @@ export class {{classname}} {

{{/hasFormParams}}
{{#useHttpClient}}
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<any>{{/isResponseFile}}(`${this.basePath}{{{path}}}`, {{#bodyParam}}{{paramName}}, {{/bodyParam}}
{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams, {{/hasFormParams}}{
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<any>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}}, {{/isBodyAllowed}}
{
{{#hasQueryParams}}
params: queryParameters,
params: queryParameters,
{{/hasQueryParams}}
headers: headers,
headers: headers,
{{#isResponseFile}}
responseType: "blob",
responseType: "blob",
{{/isResponseFile}}
withCredentials: this.configuration.withCredentials,
});
withCredentials: this.configuration.withCredentials,
}
);
{{/useHttpClient}}
{{^useHttpClient}}
let requestOptions: RequestOptionsArgs = new RequestOptions({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ export class PetService {
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}

return this.httpClient.post<any>(`${this.basePath}/pet`, body,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.post<any>(`${this.basePath}/pet`,
body,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand All @@ -109,11 +111,12 @@ export class PetService {
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}

return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand Down Expand Up @@ -141,12 +144,13 @@ export class PetService {
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}

return this.httpClient.get<any>(`${this.basePath}/pet/findByStatus`,
{
params: queryParameters,
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.get<any>(`${this.basePath}/pet/findByStatus`,
{
params: queryParameters,
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand Down Expand Up @@ -174,12 +178,13 @@ export class PetService {
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}

return this.httpClient.get<any>(`${this.basePath}/pet/findByTags`,
{
params: queryParameters,
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.get<any>(`${this.basePath}/pet/findByTags`,
{
params: queryParameters,
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand All @@ -199,11 +204,12 @@ export class PetService {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
}

return this.httpClient.get<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.get<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand All @@ -226,11 +232,13 @@ export class PetService {
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}

return this.httpClient.put<any>(`${this.basePath}/pet`, body,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.put<any>(`${this.basePath}/pet`,
body,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand Down Expand Up @@ -279,11 +287,13 @@ export class PetService {
formParams = formParams.append('status', <any>status) || formParams;
}

return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
convertFormParamsToString ? formParams.toString() : formParams, {
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
convertFormParamsToString ? formParams.toString() : formParams,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand Down Expand Up @@ -335,11 +345,13 @@ export class PetService {
formParams = formParams.append('file', <any>file) || formParams;
}

return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
convertFormParamsToString ? formParams.toString() : formParams, {
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
convertFormParamsToString ? formParams.toString() : formParams,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ export class StoreService {

let headers = this.defaultHeaders;

return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand All @@ -89,11 +90,12 @@ export class StoreService {
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
}

return this.httpClient.get<any>(`${this.basePath}/store/inventory`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.get<any>(`${this.basePath}/store/inventory`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand All @@ -108,11 +110,12 @@ export class StoreService {

let headers = this.defaultHeaders;

return this.httpClient.get<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.get<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

/**
Expand All @@ -127,11 +130,13 @@ export class StoreService {

let headers = this.defaultHeaders;

return this.httpClient.post<any>(`${this.basePath}/store/order`, body,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
});
return this.httpClient.post<any>(`${this.basePath}/store/order`,
body,
{
headers: headers,
withCredentials: this.configuration.withCredentials,
}
);
}

}
Loading