diff --git a/CHANGELOG.md b/CHANGELOG.md index 814663f9f5..9c682fe49d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed bug where base64url types would not be generated properly in Java. - Fixed bug where symbol name cleanup would not work on forward single quotes characters [#3426](https://github.com/microsoft/kiota/issues/3426). - Fixed a bug where a "models" API path segment in the description would derail generation. [#3400](https://github.com/microsoft/kiota/issues/3400) +- Changes to the configuration of RequestInformation are preserved instead of being overwritten. [#3401](https://github.com/microsoft/kiota/pull/3401). - Fix bug where import statements in typescript wasn't using import type notation for types that are erased at runtime. [#3190](https://github.com/microsoft/kiota/issues/3190) ## [1.7.0] - 2023-10-05 @@ -78,7 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Flattens the models namespaces in Ruby to avoid circular dependencies. - Adds ObjectId as a reserved keyword in Ruby to have memory management issues. - Replace Javax annotations in favor of Jakarta annotations for Java code generation. [#2810](https://github.com/microsoft/kiota/issues/2810) -- RequestExecuters call overload methods reducing code generation size for Java. [#3150](https://github.com/microsoft/kiota/issues/3150) +- RequestExecuters call overload methods reducing code generation size for Java. [#3150](https://github.com/microsoft/kiota/issues/3150) - Remove URISyntaxException from Java generated RequestExecutors and RequestGenerators. [#3149](https://github.com/microsoft/kiota/issues/3149) - Adds 'Generated' annotation to generated Enums and Classes for Java. [#3106](https://github.com/microsoft/kiota/issues/3106) - Fixes uuid conversion to string value in PathParameters in Go. [#3106](https://github.com/microsoft/kiota/issues/3176) @@ -238,15 +239,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.1.0] - 2023-04-05 ### Added - + - Added Visual Studio Code preview extension. [#2333](https://github.com/microsoft/kiota/issues/2333) - Added support for searching in forks for API descriptions in GitHub. [#2429](https://github.com/microsoft/kiota/issues/2429) - Added the ability to filter on operations. [#2431](https://github.com/microsoft/kiota/issues/2431) ### Changed -- Fixed a bug where UUID type is not correctly passed to deserialization method due to snake casing of primitive type names. -- Fixed a bug where unescaped query parameters are not correctly matched to the original name due to python convention of snake casing parameter names. +- Fixed a bug where UUID type is not correctly passed to deserialization method due to snake casing of primitive type names. +- Fixed a bug where unescaped query parameters are not correctly matched to the original name due to python convention of snake casing parameter names. - Fixed a bug where date types annotations and guid's were not correctly translated in Python - Fixed the extension of downloaded files when using the default path. [#2316](https://github.com/microsoft/kiota/issues/2316) - Fixed a bug where lookup of reference ids failed for AllOf more than one level up. @@ -1104,4 +1105,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial GitHub release - diff --git a/it/go/go.mod b/it/go/go.mod index cce5813307..2b64da67d0 100644 --- a/it/go/go.mod +++ b/it/go/go.mod @@ -3,10 +3,10 @@ module integrationtest go 1.20 require ( - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 - github.com/microsoft/kiota-abstractions-go v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 + github.com/microsoft/kiota-abstractions-go v1.3.0 github.com/microsoft/kiota-authentication-azure-go v1.0.0 - github.com/microsoft/kiota-http-go v1.0.0 + github.com/microsoft/kiota-http-go v1.1.0 github.com/microsoft/kiota-serialization-form-go v1.0.0 github.com/microsoft/kiota-serialization-json-go v1.0.4 github.com/microsoft/kiota-serialization-multipart-go v1.0.0 @@ -14,26 +14,26 @@ require ( ) require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect github.com/cjlapao/common-go v0.0.39 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/std-uritemplate/std-uritemplate/go v0.0.43 // indirect github.com/stretchr/testify v1.8.4 // indirect - github.com/yosida95/uritemplate/v3 v3.0.2 // indirect - go.opentelemetry.io/otel v1.16.0 // indirect - go.opentelemetry.io/otel/metric v1.16.0 // indirect - go.opentelemetry.io/otel/trace v1.16.0 // indirect - golang.org/x/crypto v0.10.0 // indirect - golang.org/x/net v0.11.0 // indirect - golang.org/x/sys v0.9.0 // indirect - golang.org/x/text v0.10.0 // indirect + go.opentelemetry.io/otel v1.19.0 // indirect + go.opentelemetry.io/otel/metric v1.19.0 // indirect + go.opentelemetry.io/otel/trace v1.19.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/it/go/go.sum b/it/go/go.sum index 2ae860c463..72d599f858 100644 --- a/it/go/go.sum +++ b/it/go/go.sum @@ -1,36 +1,36 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 h1:9kDVnTz3vbfweTqAUmk/a/pH5pWFCHtvRpHYC0G/dcA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 h1:hVeq+yCyUi+MsoO/CU95yqCIcdzra5ovzk8Q2BBpV2M= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/cjlapao/common-go v0.0.39 h1:bAAUrj2B9v0kMzbAOhzjSmiyDy+rd56r2sy7oEiQLlA= github.com/cjlapao/common-go v0.0.39/go.mod h1:M3dzazLjTjEtZJbbxoA5ZDiGCiHmpwqW9l4UWaddwOA= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/microsoft/kiota-abstractions-go v1.2.0 h1:lUriJgqdCY/QajwWQOgTCQE9Atywfe2NHhgoTCSXTRE= -github.com/microsoft/kiota-abstractions-go v1.2.0/go.mod h1:RkxyZ5x87Njik7iVeQY9M2wtrrL1MJZcXiI/BxD/82g= +github.com/microsoft/kiota-abstractions-go v1.3.0 h1:mZTAg+Lf43+hoqTYWT53F/Dg+f0bqtHULnTI/GyiXn8= +github.com/microsoft/kiota-abstractions-go v1.3.0/go.mod h1:yPSuzNSOIVQSFFe1iT+3Lu5zmis22E8Wg+bkyjhd+pY= github.com/microsoft/kiota-authentication-azure-go v1.0.0 h1:29FNZZ/4nnCOwFcGWlB/sxPvWz487HA2bXH8jR5k2Rk= github.com/microsoft/kiota-authentication-azure-go v1.0.0/go.mod h1:rnx3PRlkGdXDcA/0lZQTbBwyYGmc+3POt7HpE/e4jGw= -github.com/microsoft/kiota-http-go v1.0.0 h1:F1hd6gMlLeEgH2CkRB7z13ow7LxMKMWEmms/t0VfS+k= -github.com/microsoft/kiota-http-go v1.0.0/go.mod h1:eujxJliqodotsYepIc6ihhK+vXMMt5Q8YiSNL7+7M7U= +github.com/microsoft/kiota-http-go v1.1.0 h1:L5I93EiNtlP/X6YzeTlhjWt7Q1DxzC9CmWSVtX3b0tE= +github.com/microsoft/kiota-http-go v1.1.0/go.mod h1:zESUM6ovki9LEupqziCbxJ+FAYoF0dFDYZVpOkAfSLc= github.com/microsoft/kiota-serialization-form-go v1.0.0 h1:UNdrkMnLFqUCccQZerKjblsyVgifS11b3WCx+eFEsAI= github.com/microsoft/kiota-serialization-form-go v1.0.0/go.mod h1:h4mQOO6KVTNciMF6azi1J9QB19ujSw3ULKcSNyXXOMA= github.com/microsoft/kiota-serialization-json-go v1.0.4 h1:5TaISWwd2Me8clrK7SqNATo0tv9seOq59y4I5953egQ= @@ -43,26 +43,25 @@ github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/std-uritemplate/std-uritemplate/go v0.0.43 h1:uCK+SVkfF0ij1HbOViU6m5xDKuQvrq381MvsMQVOsPw= +github.com/std-uritemplate/std-uritemplate/go v0.0.43/go.mod h1:Qov4Ay4U83j37XjgxMYevGJFLbnZ2o9cEOhGufBKgKY= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= -github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= -go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= -go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= -go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= -go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= -go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= -go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= -golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= +go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= +go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= +go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= +go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= +go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/it/java/basic/pom.xml b/it/java/basic/pom.xml index b065cd20b8..ada2ca43c7 100644 --- a/it/java/basic/pom.xml +++ b/it/java/basic/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.6.0 + 0.7.8 diff --git a/it/java/pom.xml b/it/java/pom.xml index ffd3420d01..642498c25e 100644 --- a/it/java/pom.xml +++ b/it/java/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.6.0 + 0.7.8 diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index dd95265e3c..8bbf7c0845 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -418,19 +418,6 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req writer.WriteLines($"UrlTemplate = {GetPropertyCall(urlTemplateProperty, "string.Empty")},", $"PathParameters = {GetPropertyCall(urlTemplateParamsProperty, "string.Empty")},"); writer.CloseBlock("};"); - if (codeElement.AcceptedResponseTypes.Any()) - writer.WriteLine($"{RequestInfoVarName}.Headers.Add(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\");"); - if (requestParams.requestBody != null) - { - var suffix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; - if (requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase)) - writer.WriteLine($"{RequestInfoVarName}.SetStreamContent({requestParams.requestBody.Name});"); - else if (currentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) is CodeProperty requestAdapterProperty) - if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) - writer.WriteLine($"{RequestInfoVarName}.SetContentFromParsable({requestAdapterProperty.Name.ToFirstCharacterUpperCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name});"); - else - writer.WriteLine($"{RequestInfoVarName}.SetContentFromScalar{suffix}({requestAdapterProperty.Name.ToFirstCharacterUpperCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name});"); - } if (requestParams.requestConfiguration != null) { @@ -445,6 +432,21 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req $"{RequestInfoVarName}.AddHeaders({RequestConfigVarName}.Headers);"); writer.CloseBlock(); } + + if (codeElement.AcceptedResponseTypes.Any()) + writer.WriteLine($"{RequestInfoVarName}.Headers.TryAdd(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\");"); + if (requestParams.requestBody != null) + { + var suffix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; + if (requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase)) + writer.WriteLine($"{RequestInfoVarName}.SetStreamContent({requestParams.requestBody.Name});"); + else if (currentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) is CodeProperty requestAdapterProperty) + if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) + writer.WriteLine($"{RequestInfoVarName}.SetContentFromParsable({requestAdapterProperty.Name.ToFirstCharacterUpperCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name});"); + else + writer.WriteLine($"{RequestInfoVarName}.SetContentFromScalar{suffix}({requestAdapterProperty.Name.ToFirstCharacterUpperCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name});"); + } + writer.WriteLine($"return {RequestInfoVarName};"); } private static string GetPropertyCall(CodeProperty property, string defaultValue) => property == null ? defaultValue : $"{property.Name.ToFirstCharacterUpperCase()}"; diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs index 73364bc8fb..7055214838 100644 --- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs @@ -819,33 +819,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req var requestAdapterPropertyName = BaseRequestBuilderVarName + "." + parentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter)?.Name.ToFirstCharacterUpperCase(); var contextParameterName = codeElement.Parameters.OfKind(CodeParameterKind.Cancellation)?.Name.ToFirstCharacterLowerCase(); writer.WriteLine($"{RequestInfoVarName} := {conventions.AbstractionsHash}.NewRequestInformation()"); - if (parentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty && - parentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty) - writer.WriteLines($"{RequestInfoVarName}.UrlTemplate = {GetPropertyCall(urlTemplateProperty, "\"\"")}", - $"{RequestInfoVarName}.PathParameters = {GetPropertyCall(urlTemplateParamsProperty, "\"\"")}"); - writer.WriteLine($"{RequestInfoVarName}.Method = {conventions.AbstractionsHash}.{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()}"); - if (codeElement.AcceptedResponseTypes.Any()) - writer.WriteLine($"{RequestInfoVarName}.Headers.Add(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\")"); - if (requestParams.requestBody != null) - { - var bodyParamReference = $"{requestParams.requestBody.Name.ToFirstCharacterLowerCase()}"; - var collectionSuffix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; - if (requestParams.requestBody.Type.Name.Equals("binary", StringComparison.OrdinalIgnoreCase)) - writer.WriteLine($"{RequestInfoVarName}.SetStreamContent({bodyParamReference})"); - else if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.TypeDefinition is CodeInterface || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) - { - if (bodyType.IsCollection) - { - var parsableSymbol = GetConversionHelperMethodImport(parentClass, "Parsable"); - WriteCollectionCast(parsableSymbol, bodyParamReference, "cast", writer, string.Empty, false); - bodyParamReference = "cast"; - } - writer.WriteLine($"err := {RequestInfoVarName}.SetContentFromParsable{collectionSuffix}({contextParameterName}, m.{requestAdapterPropertyName}, \"{codeElement.RequestBodyContentType}\", {bodyParamReference})"); - writer.WriteBlock("if err != nil {", "}", "return nil, err"); - } - else - writer.WriteLine($"{RequestInfoVarName}.SetContentFromScalar{collectionSuffix}({contextParameterName}, m.{requestAdapterPropertyName}, \"{codeElement.RequestBodyContentType}\", {bodyParamReference})"); - } + if (requestParams.requestConfiguration != null) { var headers = requestParams.Headers; @@ -874,6 +848,35 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req } writer.CloseBlock(); } + + if (parentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty && + parentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty) + writer.WriteLines($"{RequestInfoVarName}.UrlTemplate = {GetPropertyCall(urlTemplateProperty, "\"\"")}", + $"{RequestInfoVarName}.PathParameters = {GetPropertyCall(urlTemplateParamsProperty, "\"\"")}"); + writer.WriteLine($"{RequestInfoVarName}.Method = {conventions.AbstractionsHash}.{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()}"); + if (codeElement.AcceptedResponseTypes.Any()) + writer.WriteLine($"{RequestInfoVarName}.Headers.TryAdd(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\")"); + if (requestParams.requestBody != null) + { + var bodyParamReference = $"{requestParams.requestBody.Name.ToFirstCharacterLowerCase()}"; + var collectionSuffix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; + if (requestParams.requestBody.Type.Name.Equals("binary", StringComparison.OrdinalIgnoreCase)) + writer.WriteLine($"{RequestInfoVarName}.SetStreamContent({bodyParamReference})"); + else if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.TypeDefinition is CodeInterface || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) + { + if (bodyType.IsCollection) + { + var parsableSymbol = GetConversionHelperMethodImport(parentClass, "Parsable"); + WriteCollectionCast(parsableSymbol, bodyParamReference, "cast", writer, string.Empty, false); + bodyParamReference = "cast"; + } + writer.WriteLine($"err := {RequestInfoVarName}.SetContentFromParsable{collectionSuffix}({contextParameterName}, m.{requestAdapterPropertyName}, \"{codeElement.RequestBodyContentType}\", {bodyParamReference})"); + writer.WriteBlock("if err != nil {", "}", "return nil, err"); + } + else + writer.WriteLine($"{RequestInfoVarName}.SetContentFromScalar{collectionSuffix}({contextParameterName}, m.{requestAdapterPropertyName}, \"{codeElement.RequestBodyContentType}\", {bodyParamReference})"); + } + writer.WriteLine($"return {RequestInfoVarName}, nil"); } private const string BaseRequestBuilderVarName = "BaseRequestBuilder"; diff --git a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs index b26c9513ff..70f05ece23 100644 --- a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs @@ -541,26 +541,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if (codeElement.HttpMethod == null) throw new InvalidOperationException("http method cannot be null"); writer.WriteLine($"final RequestInformation {RequestInfoVarName} = new RequestInformation();"); - writer.WriteLine($"{RequestInfoVarName}.httpMethod = HttpMethod.{codeElement.HttpMethod.ToString()?.ToUpperInvariant()};"); - if (currentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && - currentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) - writer.WriteLines($"{RequestInfoVarName}.urlTemplate = {GetPropertyCall(urlTemplateProperty, "\"\"")};", - $"{RequestInfoVarName}.pathParameters = {GetPropertyCall(urlTemplateParamsProperty, "null")};"); - if (codeElement.AcceptedResponseTypes.Any()) - writer.WriteLine($"{RequestInfoVarName}.headers.add(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\");"); - if (requestParams.requestBody != null && - currentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) is CodeProperty requestAdapterProperty) - { - var toArrayPostfix = requestParams.requestBody.Type.IsCollection ? $".toArray(new {requestParams.requestBody.Type.Name}[0])" : string.Empty; - var collectionPostfix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; - if (requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase)) - writer.WriteLine($"{RequestInfoVarName}.setStreamContent({requestParams.requestBody.Name});"); - else if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) - writer.WriteLine($"{RequestInfoVarName}.setContentFromParsable({requestAdapterProperty.Name}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name}{toArrayPostfix});"); - else - writer.WriteLine($"{RequestInfoVarName}.setContentFromScalar{collectionPostfix}({requestAdapterProperty.Name}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name}{toArrayPostfix});"); - } if (requestParams.requestConfiguration != null) { writer.WriteLine($"if ({requestParams.requestConfiguration.Name} != null) {{"); @@ -580,6 +561,27 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req writer.CloseBlock(); } + writer.WriteLine($"{RequestInfoVarName}.httpMethod = HttpMethod.{codeElement.HttpMethod.ToString()?.ToUpperInvariant()};"); + if (currentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && + currentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) + writer.WriteLines($"{RequestInfoVarName}.urlTemplate = {GetPropertyCall(urlTemplateProperty, "\"\"")};", + $"{RequestInfoVarName}.pathParameters = {GetPropertyCall(urlTemplateParamsProperty, "null")};"); + if (codeElement.AcceptedResponseTypes.Any()) + writer.WriteLine($"{RequestInfoVarName}.headers.tryAdd(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\");"); + + if (requestParams.requestBody != null && + currentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) is CodeProperty requestAdapterProperty) + { + var toArrayPostfix = requestParams.requestBody.Type.IsCollection ? $".toArray(new {requestParams.requestBody.Type.Name}[0])" : string.Empty; + var collectionPostfix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; + if (requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase)) + writer.WriteLine($"{RequestInfoVarName}.setStreamContent({requestParams.requestBody.Name});"); + else if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) + writer.WriteLine($"{RequestInfoVarName}.setContentFromParsable({requestAdapterProperty.Name}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name}{toArrayPostfix});"); + else + writer.WriteLine($"{RequestInfoVarName}.setContentFromScalar{collectionPostfix}({requestAdapterProperty.Name}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name}{toArrayPostfix});"); + } + writer.WriteLine($"return {RequestInfoVarName};"); } private static string GetPropertyCall(CodeProperty property, string defaultValue) => property == null ? defaultValue : $"{property.Name}"; diff --git a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs index 5fc92e6d0a..01fa5de23b 100644 --- a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs @@ -555,8 +555,8 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req writer.WriteLines($"{RequestInfoVarName}->urlTemplate = {GetPropertyCall(urlTemplateProperty, "''")};", $"{RequestInfoVarName}->pathParameters = {GetPropertyCall(pathParametersProperty, "''")};"); writer.WriteLine($"{RequestInfoVarName}->httpMethod = HttpMethod::{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()};"); - WriteAcceptHeaderDef(codeElement, writer); WriteRequestConfiguration(requestParams, writer); + WriteAcceptHeaderDef(codeElement, writer); if (requestParams.requestBody != null) { var suffix = requestParams.requestBody.Type.IsCollection ? "Collection" : string.Empty; @@ -599,7 +599,7 @@ private void WriteRequestConfiguration(RequestParams requestParams, LanguageWrit private void WriteAcceptHeaderDef(CodeMethod codeMethod, LanguageWriter writer) { if (codeMethod.AcceptedResponseTypes.Any()) - writer.WriteLine($"{RequestInfoVarName}->addHeader('Accept', \"{string.Join(", ", codeMethod.AcceptedResponseTypes)}\");"); + writer.WriteLine($"{RequestInfoVarName}->tryAddHeader('Accept', \"{string.Join(", ", codeMethod.AcceptedResponseTypes)}\");"); } private void WriteDeserializerBody(CodeClass parentClass, LanguageWriter writer, CodeMethod method, bool extendsModelClass = false) { diff --git a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs index 65b0ec8c4a..9a400cd7df 100644 --- a/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs @@ -610,14 +610,14 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if (codeElement.HttpMethod == null) throw new InvalidOperationException("http method cannot be null"); writer.WriteLine($"{RequestInfoVarName} = RequestInformation()"); + UpdateRequestInformationFromRequestConfiguration(requestParams, writer); if (currentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && currentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) writer.WriteLines($"{RequestInfoVarName}.url_template = {GetPropertyCall(urlTemplateProperty, "''")}", $"{RequestInfoVarName}.path_parameters = {GetPropertyCall(urlTemplateParamsProperty, "''")}"); writer.WriteLine($"{RequestInfoVarName}.http_method = Method.{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()}"); if (codeElement.AcceptedResponseTypes.Any()) - writer.WriteLine($"{RequestInfoVarName}.headers[\"Accept\"] = [\"{string.Join(", ", codeElement.AcceptedResponseTypes)}\"]"); - UpdateRequestInformationFromRequestConfiguration(requestParams, writer); + writer.WriteLine($"{RequestInfoVarName}.try_add_request_header(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\")"); if (currentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) is CodeProperty requestAdapterProperty) UpdateRequestInformationFromRequestBody(codeElement, requestParams, requestAdapterProperty, writer); writer.WriteLine($"return {RequestInfoVarName}"); diff --git a/src/Kiota.Builder/Writers/Ruby/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Ruby/CodeMethodWriter.cs index a6ee1d88d6..cbccdf170a 100644 --- a/src/Kiota.Builder/Writers/Ruby/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Ruby/CodeMethodWriter.cs @@ -281,13 +281,6 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if (codeElement.HttpMethod == null) throw new InvalidOperationException("http method cannot be null"); writer.WriteLine("request_info = MicrosoftKiotaAbstractions::RequestInformation.new()"); - if (parentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && - parentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) - writer.WriteLines($"request_info.url_template = {GetPropertyCall(urlTemplateProperty, "''")}", - $"request_info.path_parameters = {GetPropertyCall(urlTemplateParamsProperty, "''")}"); - writer.WriteLine($"request_info.http_method = :{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()}"); - if (codeElement.AcceptedResponseTypes.Any()) - writer.WriteLine($"request_info.headers.add('Accept', '{string.Join(", ", codeElement.AcceptedResponseTypes)}')"); if (requestParams.requestConfiguration != null) { var queryString = requestParams.QueryParameters; @@ -313,6 +306,13 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req writer.WriteLine($"request_info.set_content_from_parsable(@{requestAdapterProperty.Name.ToSnakeCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name})"); } } + if (parentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && + parentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) + writer.WriteLines($"request_info.url_template = {GetPropertyCall(urlTemplateProperty, "''")}", + $"request_info.path_parameters = {GetPropertyCall(urlTemplateParamsProperty, "''")}"); + writer.WriteLine($"request_info.http_method = :{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()}"); + if (codeElement.AcceptedResponseTypes.Any()) + writer.WriteLine($"request_info.headers.try_add('Accept', '{string.Join(", ", codeElement.AcceptedResponseTypes)}')"); writer.WriteLine("return request_info"); } private static string GetPropertyCall(CodeProperty property, string defaultValue) => property == null ? defaultValue : $"@{property.NamePrefix}{property.Name.ToSnakeCase()}"; diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs index e68845ae38..42f5354569 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs @@ -345,13 +345,6 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if (codeElement.HttpMethod == null) throw new InvalidOperationException("http method cannot be null"); writer.WriteLine($"const {RequestInfoVarName} = new RequestInformation();"); - if (currentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && - currentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) - writer.WriteLines($"{RequestInfoVarName}.urlTemplate = {GetPropertyCall(urlTemplateProperty)};", - $"{RequestInfoVarName}.pathParameters = {GetPropertyCall(urlTemplateParamsProperty)};"); - writer.WriteLine($"{RequestInfoVarName}.httpMethod = HttpMethod.{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()};"); - if (codeElement.AcceptedResponseTypes.Any()) - writer.WriteLine($"{RequestInfoVarName}.headers[\"Accept\"] = [\"{string.Join(", ", codeElement.AcceptedResponseTypes)}\"];"); if (requestParams.requestConfiguration != null) { writer.WriteLine($"if ({requestParams.requestConfiguration.Name}) {{"); @@ -367,6 +360,13 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req writer.WriteLine($"{RequestInfoVarName}.addRequestOptions({requestParams.requestConfiguration.Name}.{options.Name});"); writer.CloseBlock(); } + if (currentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty && + currentClass.GetPropertyOfKind(CodePropertyKind.UrlTemplate) is CodeProperty urlTemplateProperty) + writer.WriteLines($"{RequestInfoVarName}.urlTemplate = {GetPropertyCall(urlTemplateProperty)};", + $"{RequestInfoVarName}.pathParameters = {GetPropertyCall(urlTemplateParamsProperty)};"); + writer.WriteLine($"{RequestInfoVarName}.httpMethod = HttpMethod.{codeElement.HttpMethod.Value.ToString().ToUpperInvariant()};"); + if (codeElement.AcceptedResponseTypes.Any()) + writer.WriteLine($"{RequestInfoVarName}.tryAddRequestHeaders(\"Accept\", \"{string.Join(", ", codeElement.AcceptedResponseTypes)}\");"); if (requestParams.requestBody != null) { if (requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase)) diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs index ec7a15c3bd..d55e5dcfe3 100644 --- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs @@ -936,7 +936,7 @@ public void WritesRequestGeneratorBodyForNullableScalar() Assert.Contains("if (config != null)", result); Assert.Contains("var requestConfig = new RequestConfig()", result); Assert.Contains("config.Invoke(requestConfig)", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains("requestInfo.AddHeaders(requestConfig.Headers)", result); Assert.Contains("requestInfo.AddQueryParameters(requestConfig.QueryParameters)", result); Assert.Contains("requestInfo.AddRequestOptions(requestConfig.Options)", result); @@ -963,7 +963,7 @@ public void WritesRequestGeneratorBodyForScalar() Assert.Contains("if (config != null)", result); Assert.Contains("var requestConfig = new RequestConfig()", result); Assert.Contains("config.Invoke(requestConfig)", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains("requestInfo.AddHeaders(requestConfig.Headers)", result); Assert.Contains("requestInfo.AddQueryParameters(requestConfig.QueryParameters)", result); Assert.Contains("requestInfo.AddRequestOptions(requestConfig.Options)", result); @@ -991,7 +991,7 @@ public void WritesRequestGeneratorBodyForParsable() Assert.Contains("if (config != null)", result); Assert.Contains("var requestConfig = new RequestConfig()", result); Assert.Contains("config.Invoke(requestConfig)", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains("requestInfo.AddHeaders(requestConfig.Headers)", result); Assert.Contains("requestInfo.AddQueryParameters(requestConfig.QueryParameters)", result); Assert.Contains("requestInfo.AddRequestOptions(requestConfig.Options)", result); diff --git a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs index 2e31b9fdc6..117d50adf9 100644 --- a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs @@ -1163,7 +1163,7 @@ public async Task WritesRequestGeneratorBodyForScalar() Assert.Contains($"requestInfo := {AbstractionsPackageHash}.NewRequestInformation()", result); Assert.Contains("requestInfo.UrlTemplate = ", result); Assert.Contains("requestInfo.PathParameters", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains($"Method = {AbstractionsPackageHash}.GET", result); Assert.Contains("if c != nil", result); Assert.Contains("requestInfo.Headers.AddAll(", result); @@ -1203,7 +1203,7 @@ public async Task WritesRequestGeneratorBodyForScalarCollection() Assert.Contains($"requestInfo := {AbstractionsPackageHash}.NewRequestInformation()", result); Assert.Contains("requestInfo.UrlTemplate = ", result); Assert.Contains("requestInfo.PathParameters", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains($"Method = {AbstractionsPackageHash}.GET", result); Assert.Contains("if c != nil", result); Assert.Contains("requestInfo.Headers.AddAll(", result); @@ -1241,7 +1241,7 @@ public async Task WritesRequestGeneratorBodyForParsable() Assert.Contains($"requestInfo := {AbstractionsPackageHash}.NewRequestInformation()", result); Assert.Contains("requestInfo.UrlTemplate = ", result); Assert.Contains("requestInfo.PathParameters", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains($"Method = {AbstractionsPackageHash}.GET", result); Assert.Contains("if c != nil", result); Assert.Contains("requestInfo.Headers.AddAll(", result); @@ -1281,7 +1281,7 @@ public async Task WritesRequestGeneratorBodyForParsableCollection() Assert.Contains($"requestInfo := {AbstractionsPackageHash}.NewRequestInformation()", result); Assert.Contains("requestInfo.UrlTemplate = ", result); Assert.Contains("requestInfo.PathParameters", result); - Assert.Contains("requestInfo.Headers.Add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.Headers.TryAdd(\"Accept\", \"application/json\")", result); Assert.Contains($"Method = {AbstractionsPackageHash}.GET", result); Assert.Contains("if c != nil", result); Assert.Contains("requestInfo.Headers.AddAll(", result); diff --git a/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs index 01078f7390..b50fdc0d87 100644 --- a/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs @@ -1192,7 +1192,7 @@ public void WritesRequestGeneratorBodyForScalar() Assert.Contains("urlTemplate =", result); Assert.Contains("pathParameters =", result); Assert.Contains("httpMethod = HttpMethod.GET", result); - Assert.Contains("requestInfo.headers.add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.headers.tryAdd(\"Accept\", \"application/json\")", result); Assert.Contains("if (c != null)", result); Assert.Contains("final RequestConfig requestConfig = new RequestConfig()", result); Assert.Contains("c.accept(requestConfig)", result); @@ -1220,7 +1220,7 @@ public void WritesRequestGeneratorBodyForScalarCollection() Assert.Contains("urlTemplate =", result); Assert.Contains("pathParameters =", result); Assert.Contains("httpMethod = HttpMethod.GET", result); - Assert.Contains("requestInfo.headers.add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.headers.tryAdd(\"Accept\", \"application/json\")", result); Assert.Contains("if (c != null)", result); Assert.Contains("final RequestConfig requestConfig = new RequestConfig()", result); Assert.Contains("c.accept(requestConfig)", result); @@ -1247,7 +1247,7 @@ public void WritesRequestGeneratorBodyForParsable() Assert.Contains("urlTemplate =", result); Assert.Contains("pathParameters =", result); Assert.Contains("httpMethod = HttpMethod.GET", result); - Assert.Contains("requestInfo.headers.add(\"Accept\", \"application/json\")", result); + Assert.Contains("requestInfo.headers.tryAdd(\"Accept\", \"application/json\")", result); Assert.Contains("if (c != null)", result); Assert.Contains("final RequestConfig requestConfig = new RequestConfig()", result); Assert.Contains("c.accept(requestConfig)", result); diff --git a/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs index a885bd4525..a17efa9aab 100644 --- a/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Python/CodeMethodWriterTests.cs @@ -673,7 +673,7 @@ public void WritesRequestGeneratorBodyForScalar() Assert.Contains("request_info.http_method = Method", result); Assert.Contains("request_info.url_template = ", result); Assert.Contains("request_info.path_parameters = ", result); - Assert.Contains("request_info.headers[\"Accept\"] = [\"application/json, text/plain\"]", result); + Assert.Contains("request_info.try_add_request_header(\"Accept\", \"application/json, text/plain\")", result); Assert.Contains("if c:", result); Assert.Contains("request_info.add_request_headers", result); Assert.Contains("request_info.add_request_options", result); @@ -698,7 +698,7 @@ public void WritesRequestGeneratorBodyForParsable() Assert.Contains("request_info.http_method = Method", result); Assert.Contains("request_info.url_template = ", result); Assert.Contains("request_info.path_parameters = ", result); - Assert.Contains("request_info.headers[\"Accept\"] = [\"application/json, text/plain\"]", result); + Assert.Contains("request_info.try_add_request_header(\"Accept\", \"application/json, text/plain\")", result); Assert.Contains("if c:", result); Assert.Contains("request_info.add_request_headers", result); Assert.Contains("request_info.add_request_options", result); diff --git a/tests/Kiota.Builder.Tests/Writers/Ruby/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Ruby/CodeMethodWriterTests.cs index ccfdeb7b0e..f08ac02348 100644 --- a/tests/Kiota.Builder.Tests/Writers/Ruby/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Ruby/CodeMethodWriterTests.cs @@ -517,7 +517,7 @@ public void WritesRequestGeneratorBody() Assert.Contains("request_info.path_parameters", result); Assert.Contains("request_info.url_template", result); Assert.Contains("http_method = :GET", result); - Assert.Contains("request_info.headers.add('Accept', 'application/json')", result); + Assert.Contains("request_info.headers.try_add('Accept', 'application/json')", result); Assert.Contains("set_query_string_parameters_from_raw_object", result); Assert.Contains("add_headers_from_raw_object", result); Assert.Contains("add_request_options", result); diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs index eb5b715349..47babf4fca 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs @@ -275,7 +275,7 @@ public void WritesRequestGeneratorBodyForScalar() Assert.Contains("requestInfo.httpMethod = HttpMethod", result); Assert.Contains("requestInfo.urlTemplate = ", result); Assert.Contains("requestInfo.pathParameters = ", result); - Assert.Contains("requestInfo.headers[\"Accept\"] = [\"application/json\"]", result); + Assert.Contains("requestInfo.tryAddRequestHeaders(\"Accept\", \"application/json\")", result); Assert.Contains("if (c)", result); Assert.Contains("requestInfo.addRequestHeaders", result); Assert.Contains("requestInfo.addRequestOptions", result); @@ -299,7 +299,7 @@ public async Task WritesRequestGeneratorBodyForParsable() Assert.Contains("requestInfo.httpMethod = HttpMethod", result); Assert.Contains("requestInfo.urlTemplate = ", result); Assert.Contains("requestInfo.pathParameters = ", result); - Assert.Contains("requestInfo.headers[\"Accept\"] = [\"application/json\"]", result); + Assert.Contains("requestInfo.tryAddRequestHeaders(\"Accept\", \"application/json\")", result); Assert.Contains("if (c)", result); Assert.Contains("requestInfo.addRequestHeaders", result); Assert.Contains("requestInfo.addRequestOptions", result);