Skip to content

Commit 95c996f

Browse files
authored
Revert supports for delete body in typescript-angular client (#10976)
* Update generated angular 12 client version * Revert "Delete body angular (#10751)" This reverts commit edb88d9. * Update generated files
1 parent f77d34b commit 95c996f

16 files changed

Lines changed: 20 additions & 47 deletions

File tree

bin/configs/typescript-angular-v12-provided-in-root-with-npm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ outputDir: samples/client/petstore/typescript-angular-v12-provided-in-root/build
33
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
44
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
55
additionalProperties:
6-
ngVersion: 12.0.0
6+
ngVersion: 12.2.0
77
npmVersion: 1.0.0
88
npmName: '@openapitools/typescript-angular-petstore'
99
npmRepository: https://skimdb.npmjs.com/registry

bin/configs/typescript-angular-v12-provided-in-root.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ outputDir: samples/client/petstore/typescript-angular-v12-provided-in-root/build
33
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
44
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
55
additionalProperties:
6-
ngVersion: 12.0.0
6+
ngVersion: 12.2.0

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,9 @@ public boolean isRestfulUpdate() {
239239
/**
240240
* Check if body param is allowed for the request method
241241
*
242-
* @return true request method is DELETE, PUT, PATCH or POST; false otherwise
243-
*/
244-
public boolean isBodyAllowed() {
245-
return Arrays.asList("DELETE","PUT", "PATCH", "POST").contains(httpMethod.toUpperCase(Locale.ROOT));
246-
}
247-
/**
248-
* Check if the request method is PUT or PATCH or POST
249-
*
250242
* @return true request method is PUT, PATCH or POST; false otherwise
251243
*/
252-
public boolean isMethodPutOrPatchOrPost() {
244+
public boolean isBodyAllowed() {
253245
return Arrays.asList("PUT", "PATCH", "POST").contains(httpMethod.toUpperCase(Locale.ROOT));
254246
}
255247

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
5555
public static final String PROVIDED_IN = "providedIn";
5656
public static final String ENFORCE_GENERIC_MODULE_WITH_PROVIDERS = "enforceGenericModuleWithProviders";
5757
public static final String HTTP_CONTEXT_IN_OPTIONS = "httpContextInOptions";
58-
public static final String DELETE_ACCEPTS_BODY = "deleteAcceptsBody";
5958
public static final String API_MODULE_PREFIX = "apiModulePrefix";
6059
public static final String CONFIGURATION_PREFIX = "configurationPrefix";
6160
public static final String SERVICE_SUFFIX = "serviceSuffix";
@@ -238,12 +237,6 @@ public void processOpts() {
238237
additionalProperties.put(HTTP_CONTEXT_IN_OPTIONS, false);
239238
}
240239

241-
if (ngVersion.atLeast("12.1.0")) {
242-
additionalProperties.put(DELETE_ACCEPTS_BODY, true);
243-
} else {
244-
additionalProperties.put(DELETE_ACCEPTS_BODY, false);
245-
}
246-
247240
additionalProperties.put(NG_VERSION, ngVersion);
248241

249242
if (additionalProperties.containsKey(API_MODULE_PREFIX)) {

modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class {{classname}} {
121121
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
122122
GenericUrl genericUrl = new GenericUrl(localVarUrl);
123123

124-
HttpContent content = {{#isMethodPutOrPatchOrPost}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isMethodPutOrPatchOrPost}}{{^isMethodPutOrPatchOrPost}}null{{/isMethodPutOrPatchOrPost}};
124+
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
125125
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
126126
}{{#bodyParam}}
127127

@@ -199,7 +199,7 @@ public class {{classname}} {
199199
String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
200200
GenericUrl genericUrl = new GenericUrl(localVarUrl);
201201

202-
HttpContent content = {{#isMethodPutOrPatchOrPost}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isMethodPutOrPatchOrPost}}{{^isMethodPutOrPatchOrPost}}null{{/isMethodPutOrPatchOrPost}};
202+
HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
203203
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
204204
}
205205

modules/openapi-generator/src/main/resources/erlang-proper/api.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
Method = {{httpMethod}},
1919
Host = application:get_env({{packageName}}, host, "http://localhost:8080"),
2020
Path = ["{{{replacedPathName}}}"],
21-
{{#isMethodPutOrPatchOrPost}}
21+
{{#isBodyAllowed}}
2222
Body = {{^formParams.isEmpty}}{form, [{{#formParams}}{{#required}}{{^-first}}, {{/-first}}{<<"{{{baseName}}}">>, {{paramName}}{{/required}}{{/formParams}}]++{{packageName}}_utils:optional_params([{{#formParams}}{{^required}}{{^-first}}, {{/-first}}'{{{baseName}}}'{{/required}}{{/formParams}}], _OptionalParams)}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}},
2323
ContentType = {{#hasConsumes}}hd([{{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}}]){{/hasConsumes}}{{^hasConsumes}}"text/plain"{{/hasConsumes}},
24-
{{/isMethodPutOrPatchOrPost}}
24+
{{/isBodyAllowed}}
2525
{{^queryParams.isEmpty}}
2626
QueryString = [{{#queryParams}}{{^-first}}, {{/-first}}<<"{{{baseName}}}=">>, {{{paramName}}}, <<"&">>{{/queryParams}}],
2727
{{/queryParams.isEmpty}}
2828

29-
{{#isMethodPutOrPatchOrPost}}
29+
{{#isBodyAllowed}}
3030
{{packageName}}_utils:request(Method, [Host, ?BASE_URL, Path{{^queryParams.isEmpty}}, <<"?">>, QueryString{{/queryParams.isEmpty}}], jsx:encode(Body), ContentType).
31-
{{/isMethodPutOrPatchOrPost}}
32-
{{^isMethodPutOrPatchOrPost}}
31+
{{/isBodyAllowed}}
32+
{{^isBodyAllowed}}
3333
{{packageName}}_utils:request(Method, [Host, ?BASE_URL, Path{{^queryParams.isEmpty}}, <<"?">>, QueryString{{/queryParams.isEmpty}}]).
34-
{{/isMethodPutOrPatchOrPost}}
34+
{{/isBodyAllowed}}
3535

3636
{{/operation}}
3737
{{/operations}}

modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,8 @@ export class {{classname}} {
361361
}
362362

363363
{{/isResponseFile}}
364-
{{#deleteAcceptsBody}}
365364
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.configuration.basePath}{{{path}}}`,{{#isBodyAllowed}}
366365
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
367-
{{/deleteAcceptsBody}}
368-
{{^deleteAcceptsBody}}
369-
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.configuration.basePath}{{{path}}}`,{{#isMethodPutOrPatchOrPost}}
370-
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isMethodPutOrPatchOrPost}}
371-
{{/deleteAcceptsBody}}
372366
{
373367
{{#httpContextInOptions}}
374368
context: localVarHttpContext,

modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ export class {{classname}} {
208208
{{/formParams}}
209209

210210
{{/hasFormParams}}
211-
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isMethodPutOrPatchOrPost}}
212-
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isMethodPutOrPatchOrPost}}
211+
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
212+
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
213213
{
214214
{{#hasQueryParams}}
215215
params: queryParameters,

samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
"build": "ng-packagr -p ng-package.json"
1313
},
1414
"peerDependencies": {
15-
"@angular/core": "^12.0.0",
15+
"@angular/core": "^12.2.0",
1616
"rxjs": "^6.6.0"
1717
},
1818
"devDependencies": {
19-
"@angular/common": "^12.0.0",
20-
"@angular/compiler": "^12.0.0",
21-
"@angular/compiler-cli": "^12.0.0",
22-
"@angular/core": "^12.0.0",
23-
"@angular/platform-browser": "^12.0.0",
19+
"@angular/common": "^12.2.0",
20+
"@angular/compiler": "^12.2.0",
21+
"@angular/compiler-cli": "^12.2.0",
22+
"@angular/core": "^12.2.0",
23+
"@angular/platform-browser": "^12.2.0",
2424
"ng-packagr": "^12.2.1",
2525
"reflect-metadata": "^0.1.3",
2626
"rxjs": "^6.6.0",

samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ export class PetService {
232232
}
233233

234234
return this.httpClient.delete<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
235-
null,
236235
{
237236
context: localVarHttpContext,
238237
responseType: <any>responseType_,

0 commit comments

Comments
 (0)