forked from loafle/openapi-generator-original
Bugfix/6649 angular http client empty body (#6754)
* fix empty body issue * #6649: add line break * #6649: improve indentation * #6649: improve indentation * #6649: generate code * #6649: generate samples * #6649: fix method docs
This commit is contained in:
@@ -140,6 +140,15 @@ public class CodegenOperation {
|
||||
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
|
||||
*
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,11 +69,13 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.post<any>(`${this.basePath}/user`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,11 +90,13 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,11 +111,13 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,11 +132,12 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,11 +152,12 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,12 +184,13 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/login`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/login`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,11 +201,12 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,11 +225,13 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@ export interface Order {
|
||||
}
|
||||
export namespace Order {
|
||||
export type StatusEnum = 'placed' | 'approved' | 'delivered';
|
||||
export const StatusEnum = {
|
||||
Placed: 'placed' as StatusEnum,
|
||||
Approved: 'approved' as StatusEnum,
|
||||
Delivered: 'delivered' as StatusEnum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,9 +29,6 @@ export interface Pet {
|
||||
}
|
||||
export namespace Pet {
|
||||
export type StatusEnum = 'available' | 'pending' | 'sold';
|
||||
export const StatusEnum = {
|
||||
Available: 'available' as StatusEnum,
|
||||
Pending: 'pending' as StatusEnum,
|
||||
Sold: 'sold' as StatusEnum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user