diff --git a/bin/configs/typescript-angular-v12-provided-in-root-with-npm.yaml b/bin/configs/typescript-angular-v12-provided-in-root-with-npm.yaml index 85973a9a5df..35ae77b6f82 100644 --- a/bin/configs/typescript-angular-v12-provided-in-root-with-npm.yaml +++ b/bin/configs/typescript-angular-v12-provided-in-root-with-npm.yaml @@ -3,7 +3,7 @@ outputDir: samples/client/petstore/typescript-angular-v12-provided-in-root/build inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/typescript-angular additionalProperties: - ngVersion: 12.0.0 + ngVersion: 12.2.0 npmVersion: 1.0.0 npmName: '@openapitools/typescript-angular-petstore' npmRepository: https://skimdb.npmjs.com/registry diff --git a/bin/configs/typescript-angular-v12-provided-in-root.yaml b/bin/configs/typescript-angular-v12-provided-in-root.yaml index 466282bf228..746de9795ec 100644 --- a/bin/configs/typescript-angular-v12-provided-in-root.yaml +++ b/bin/configs/typescript-angular-v12-provided-in-root.yaml @@ -3,4 +3,4 @@ outputDir: samples/client/petstore/typescript-angular-v12-provided-in-root/build inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/typescript-angular additionalProperties: - ngVersion: 12.0.0 + ngVersion: 12.2.0 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java index ca0cca500cd..9067d55dfd1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java @@ -239,17 +239,9 @@ public class CodegenOperation { /** * Check if body param is allowed for the request method * - * @return true request method is DELETE, PUT, PATCH or POST; false otherwise - */ - public boolean isBodyAllowed() { - return Arrays.asList("DELETE","PUT", "PATCH", "POST").contains(httpMethod.toUpperCase(Locale.ROOT)); - } - /** - * Check if the request method is PUT or PATCH or POST - * * @return true request method is PUT, PATCH or POST; false otherwise */ - public boolean isMethodPutOrPatchOrPost() { + public boolean isBodyAllowed() { return Arrays.asList("PUT", "PATCH", "POST").contains(httpMethod.toUpperCase(Locale.ROOT)); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java index d2ab116ab1e..d26ae474737 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java @@ -55,7 +55,6 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public static final String PROVIDED_IN = "providedIn"; public static final String ENFORCE_GENERIC_MODULE_WITH_PROVIDERS = "enforceGenericModuleWithProviders"; public static final String HTTP_CONTEXT_IN_OPTIONS = "httpContextInOptions"; - public static final String DELETE_ACCEPTS_BODY = "deleteAcceptsBody"; public static final String API_MODULE_PREFIX = "apiModulePrefix"; public static final String CONFIGURATION_PREFIX = "configurationPrefix"; public static final String SERVICE_SUFFIX = "serviceSuffix"; @@ -238,12 +237,6 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode additionalProperties.put(HTTP_CONTEXT_IN_OPTIONS, false); } - if (ngVersion.atLeast("12.1.0")) { - additionalProperties.put(DELETE_ACCEPTS_BODY, true); - } else { - additionalProperties.put(DELETE_ACCEPTS_BODY, false); - } - additionalProperties.put(NG_VERSION, ngVersion); if (additionalProperties.containsKey(API_MODULE_PREFIX)) { diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache index 97b1dd6885c..f9af1a4a9bb 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/api.mustache @@ -121,7 +121,7 @@ public class {{classname}} { String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}} GenericUrl genericUrl = new GenericUrl(localVarUrl); - HttpContent content = {{#isMethodPutOrPatchOrPost}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isMethodPutOrPatchOrPost}}{{^isMethodPutOrPatchOrPost}}null{{/isMethodPutOrPatchOrPost}}; + HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}}; return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute(); }{{#bodyParam}} @@ -199,7 +199,7 @@ public class {{classname}} { String localVarUrl = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}} GenericUrl genericUrl = new GenericUrl(localVarUrl); - HttpContent content = {{#isMethodPutOrPatchOrPost}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isMethodPutOrPatchOrPost}}{{^isMethodPutOrPatchOrPost}}null{{/isMethodPutOrPatchOrPost}}; + HttpContent content = {{#isBodyAllowed}}{{#bodyParam}}apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}new EmptyContent(){{/bodyParam}}{{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}}; return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute(); } diff --git a/modules/openapi-generator/src/main/resources/erlang-proper/api.mustache b/modules/openapi-generator/src/main/resources/erlang-proper/api.mustache index 2ee4b7eafa8..30d2b92d236 100644 --- a/modules/openapi-generator/src/main/resources/erlang-proper/api.mustache +++ b/modules/openapi-generator/src/main/resources/erlang-proper/api.mustache @@ -18,20 +18,20 @@ Method = {{httpMethod}}, Host = application:get_env({{packageName}}, host, "http://localhost:8080"), Path = ["{{{replacedPathName}}}"], - {{#isMethodPutOrPatchOrPost}} + {{#isBodyAllowed}} 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}}, ContentType = {{#hasConsumes}}hd([{{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}}]){{/hasConsumes}}{{^hasConsumes}}"text/plain"{{/hasConsumes}}, - {{/isMethodPutOrPatchOrPost}} + {{/isBodyAllowed}} {{^queryParams.isEmpty}} QueryString = [{{#queryParams}}{{^-first}}, {{/-first}}<<"{{{baseName}}}=">>, {{{paramName}}}, <<"&">>{{/queryParams}}], {{/queryParams.isEmpty}} - {{#isMethodPutOrPatchOrPost}} + {{#isBodyAllowed}} {{packageName}}_utils:request(Method, [Host, ?BASE_URL, Path{{^queryParams.isEmpty}}, <<"?">>, QueryString{{/queryParams.isEmpty}}], jsx:encode(Body), ContentType). - {{/isMethodPutOrPatchOrPost}} - {{^isMethodPutOrPatchOrPost}} + {{/isBodyAllowed}} + {{^isBodyAllowed}} {{packageName}}_utils:request(Method, [Host, ?BASE_URL, Path{{^queryParams.isEmpty}}, <<"?">>, QueryString{{/queryParams.isEmpty}}]). - {{/isMethodPutOrPatchOrPost}} + {{/isBodyAllowed}} {{/operation}} {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache index 3f5bb626a41..dee0ffaf3a4 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache @@ -361,14 +361,8 @@ export class {{classname}} { } {{/isResponseFile}} - {{#deleteAcceptsBody}} return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.configuration.basePath}{{{path}}}`,{{#isBodyAllowed}} {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}} - {{/deleteAcceptsBody}} - {{^deleteAcceptsBody}} - return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.configuration.basePath}{{{path}}}`,{{#isMethodPutOrPatchOrPost}} - {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isMethodPutOrPatchOrPost}} - {{/deleteAcceptsBody}} { {{#httpContextInOptions}} context: localVarHttpContext, diff --git a/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache index ddea339cf17..1d3703f50d7 100644 --- a/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache @@ -208,8 +208,8 @@ export class {{classname}} { {{/formParams}} {{/hasFormParams}} - return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isMethodPutOrPatchOrPost}} - {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isMethodPutOrPatchOrPost}} + return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}} + {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}} { {{#hasQueryParams}} params: queryParameters, diff --git a/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/package.json b/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/package.json index 69a4fcbf2b3..3c3b1243568 100644 --- a/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/package.json +++ b/samples/client/petstore/typescript-angular-v12-provided-in-root/builds/with-npm/package.json @@ -12,15 +12,15 @@ "build": "ng-packagr -p ng-package.json" }, "peerDependencies": { - "@angular/core": "^12.0.0", + "@angular/core": "^12.2.0", "rxjs": "^6.6.0" }, "devDependencies": { - "@angular/common": "^12.0.0", - "@angular/compiler": "^12.0.0", - "@angular/compiler-cli": "^12.0.0", - "@angular/core": "^12.0.0", - "@angular/platform-browser": "^12.0.0", + "@angular/common": "^12.2.0", + "@angular/compiler": "^12.2.0", + "@angular/compiler-cli": "^12.2.0", + "@angular/core": "^12.2.0", + "@angular/platform-browser": "^12.2.0", "ng-packagr": "^12.2.1", "reflect-metadata": "^0.1.3", "rxjs": "^6.6.0", diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/pet.service.ts index c68d5a82d52..dcc8df3f3c8 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/pet.service.ts @@ -232,7 +232,6 @@ export class PetService { } return this.httpClient.delete(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, - null, { context: localVarHttpContext, responseType: responseType_, diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/store.service.ts index b63e9dbea89..06d4df352ea 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/store.service.ts @@ -133,7 +133,6 @@ export class StoreService { } return this.httpClient.delete(`${this.configuration.basePath}/store/order/${encodeURIComponent(String(orderId))}`, - null, { context: localVarHttpContext, responseType: responseType_, diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/user.service.ts index a2e40fa8a18..a820ab29631 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/default/api/user.service.ts @@ -329,7 +329,6 @@ export class UserService { } return this.httpClient.delete(`${this.configuration.basePath}/user/${encodeURIComponent(String(username))}`, - null, { context: localVarHttpContext, responseType: responseType_, diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/pet.service.ts index c68d5a82d52..dcc8df3f3c8 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/pet.service.ts @@ -232,7 +232,6 @@ export class PetService { } return this.httpClient.delete(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, - null, { context: localVarHttpContext, responseType: responseType_, diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/store.service.ts index b63e9dbea89..06d4df352ea 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/store.service.ts @@ -133,7 +133,6 @@ export class StoreService { } return this.httpClient.delete(`${this.configuration.basePath}/store/order/${encodeURIComponent(String(orderId))}`, - null, { context: localVarHttpContext, responseType: responseType_, diff --git a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/user.service.ts index a2e40fa8a18..a820ab29631 100644 --- a/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v13-provided-in-root/builds/with-npm/api/user.service.ts @@ -329,7 +329,6 @@ export class UserService { } return this.httpClient.delete(`${this.configuration.basePath}/user/${encodeURIComponent(String(username))}`, - null, { context: localVarHttpContext, responseType: responseType_, diff --git a/samples/yaml/pet.yml b/samples/yaml/pet.yml index 4b3420c99c8..ab33f8aab1d 100644 --- a/samples/yaml/pet.yml +++ b/samples/yaml/pet.yml @@ -178,4 +178,4 @@ models: type: string id: type: integer - format: int64 \ No newline at end of file + format: int64