diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 548fcecfd9..dce5e47726 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,7 +2,6 @@ "recommendations": [ "formulahendry.dotnet-test-explorer", "ms-dotnettools.csharp", - "editorconfig.editorconfig", - "ms-dotnettools.blazorwasm-companion" + "editorconfig.editorconfig" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index e85f6e2a12..bc372e5783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added capability to serialize and deserialize UUIDs in typescript[#40](https://github.com/microsoft/kiota-typescript/issues/40) - Use `import type` statement if the generated code is an interface[#2959](https://github.com/microsoft/kiota/issues/2959) - Added auto-generation header for class and enums in CSharp [#2886](https://github.com/microsoft/kiota/issues/2886) +- Added support for multipart form data request body in CSharp, Go, Java, and TypeScript. [#220](https://github.com/microsoft/kiota/issues/220) +- Added support for base64 encoded properties in TypeScript. ### Changed diff --git a/README.md b/README.md index a0bdd97e72..5207901b89 100644 --- a/README.md +++ b/README.md @@ -21,15 +21,15 @@ The following table provides an overview of the languages supported by Kiota and | Language | Generation | Abstractions | Serialization | Authentication | HTTP | Required tools & dependencies | | -------- | ---------- |--------------------------------|-----------------------------------------------------------------| -------------- | ---- | -------------- | -| CSharp | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-dotnet) | [FORM](https://github.com/microsoft/kiota-serialization-form-dotnet), [JSON](https://github.com/microsoft/kiota-serialization-json-dotnet), [TEXT](https://github.com/microsoft/kiota-serialization-text-dotnet) | [Anonymous](https://github.com/microsoft/kiota-abstractions-dotnet/blob/main/src/authentication/AnonymousAuthenticationProvider.cs), [API Key](https://github.com/microsoft/kiota-abstractions-dotnet/blob/main/src/authentication/ApiKeyAuthenticationProvider.cs), [Azure](https://github.com/microsoft/kiota-authentication-azure-dotnet) | [✔](https://github.com/microsoft/kiota-http-dotnet) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/dotnet) | -| Go | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-go) | [FORM](https://github.com/microsoft/kiota-serialization-form-go), [JSON](https://github.com/microsoft/kiota-serialization-json-go), [TEXT](https://github.com/microsoft/kiota-serialization-text-go) | [Anonymous](https://github.com/microsoft/kiota-abstractions-go/blob/main/authentication/anonymous_authentication_provider.go), [API Key](https://github.com/microsoft/kiota-abstractions-go/blob/main/authentication/api_key_authentication_provider.go), [Azure](https://github.com/microsoft/kiota-authentication-azure-go/) | [✔](https://github.com/microsoft/kiota-http-go/) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/go) | -| Java | ✔ | [✔](https://github.com/microsoft/kiota-java/tree/main/components/abstractions) | [FORM](https://github.com/microsoft/kiota-java/tree/main/components/serialization/form), [JSON](https://github.com/microsoft/kiota-java/tree/main/components/serialization/json), [TEXT](https://github.com/microsoft/kiota-java/tree/main/components/serialization/text) | [Anonymous](https://github.com/microsoft/kiota-java/blob/main/components/abstractions/src/main/java/com/microsoft/kiota/authentication/AnonymousAuthenticationProvider.java), [API Key](https://github.com/microsoft/kiota-java/blob/main/components/abstractions/src/main/java/com/microsoft/kiota/authentication/ApiKeyAuthenticationProvider.java), [Azure](https://github.com/microsoft/kiota-java/tree/main/components/authentication/azure) | [✔](https://github.com/microsoft/kiota-java/tree/main/components/http/okHttp) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/java) | -| PHP | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-php) | [JSON](https://github.com/microsoft/kiota-serialization-json-php), [❌ FORM](https://github.com/microsoft/kiota/issues/2074), [TEXT](https://github.com/microsoft/kiota-serialization-text-php) | [Anonymous](https://github.com/microsoft/kiota-abstractions-php/blob/main/src/Authentication/AnonymousAuthenticationProvider.php), [✔️ PHP League](https://github.com/microsoft/kiota-authentication-phpleague-php) | [✔](https://github.com/microsoft/kiota-http-guzzle-php) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/php) | -| Python | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-python) | [❌ FORM](https://github.com/microsoft/kiota/issues/2075), [JSON](https://github.com/microsoft/kiota-serialization-json-python), [TEXT](https://github.com/microsoft/kiota-serialization-text-python) | [Anonymous](https://github.com/microsoft/kiota-abstractions-python/blob/main/kiota_abstractions/authentication/anonymous_authentication_provider.py), [Azure](https://github.com/microsoft/kiota-authentication-azure-python) | [✔](https://github.com/microsoft/kiota-http-python) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/python) | -| Ruby | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-ruby) | [❌ FORM](https://github.com/microsoft/kiota/issues/2077), [JSON](https://github.com/microsoft/kiota-serialization-json-ruby), [❌ TEXT](https://github.com/microsoft/kiota/issues/1049) | [Anonymous](https://github.com/microsoft/kiota-abstractions-ruby/blob/main/lib/microsoft_kiota_abstractions/authentication/anonymous_authentication_provider.rb), [✔️ OAuth2](https://github.com/microsoft/kiota-authentication-oauth-ruby) | [✔](https://github.com/microsoft/kiota-http-ruby)| [link](https://learn.microsoft.com/openapi/kiota/quickstarts/ruby) | +| CSharp | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-dotnet) | [FORM](https://github.com/microsoft/kiota-serialization-form-dotnet), [JSON](https://github.com/microsoft/kiota-serialization-json-dotnet), [MULTIPART](https://github.com/microsoft/kiota-serialization-multipart-dotnet), [TEXT](https://github.com/microsoft/kiota-serialization-text-dotnet) | [Anonymous](https://github.com/microsoft/kiota-abstractions-dotnet/blob/main/src/authentication/AnonymousAuthenticationProvider.cs), [API Key](https://github.com/microsoft/kiota-abstractions-dotnet/blob/main/src/authentication/ApiKeyAuthenticationProvider.cs), [Azure](https://github.com/microsoft/kiota-authentication-azure-dotnet) | [✔](https://github.com/microsoft/kiota-http-dotnet) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/dotnet) | +| Go | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-go) | [FORM](https://github.com/microsoft/kiota-serialization-form-go), [JSON](https://github.com/microsoft/kiota-serialization-json-go), [MULTIPART](https://github.com/microsoft/kiota-serialization-multipart-go), [TEXT](https://github.com/microsoft/kiota-serialization-text-go) | [Anonymous](https://github.com/microsoft/kiota-abstractions-go/blob/main/authentication/anonymous_authentication_provider.go), [API Key](https://github.com/microsoft/kiota-abstractions-go/blob/main/authentication/api_key_authentication_provider.go), [Azure](https://github.com/microsoft/kiota-authentication-azure-go/) | [✔](https://github.com/microsoft/kiota-http-go/) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/go) | +| Java | ✔ | [✔](https://github.com/microsoft/kiota-java/tree/main/components/abstractions) | [FORM](https://github.com/microsoft/kiota-java/tree/main/components/serialization/form), [JSON](https://github.com/microsoft/kiota-java/tree/main/components/serialization/json), [MULTIPART](https://github.com/microsoft/kiota-java/tree/main/components/serialization/multipart), [TEXT](https://github.com/microsoft/kiota-java/tree/main/components/serialization/text) | [Anonymous](https://github.com/microsoft/kiota-java/blob/main/components/abstractions/src/main/java/com/microsoft/kiota/authentication/AnonymousAuthenticationProvider.java), [API Key](https://github.com/microsoft/kiota-java/blob/main/components/abstractions/src/main/java/com/microsoft/kiota/authentication/ApiKeyAuthenticationProvider.java), [Azure](https://github.com/microsoft/kiota-java/tree/main/components/authentication/azure) | [✔](https://github.com/microsoft/kiota-java/tree/main/components/http/okHttp) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/java) | +| PHP | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-php) | [JSON](https://github.com/microsoft/kiota-serialization-json-php), [❌ FORM](https://github.com/microsoft/kiota/issues/2074), [❌ MULTIPART](https://github.com/microsoft/kiota/issues/3029), [TEXT](https://github.com/microsoft/kiota-serialization-text-php) | [Anonymous](https://github.com/microsoft/kiota-abstractions-php/blob/main/src/Authentication/AnonymousAuthenticationProvider.php), [✔️ PHP League](https://github.com/microsoft/kiota-authentication-phpleague-php) | [✔](https://github.com/microsoft/kiota-http-guzzle-php) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/php) | +| Python | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-python) | [❌ FORM](https://github.com/microsoft/kiota/issues/2075), [JSON](https://github.com/microsoft/kiota-serialization-json-python), [❌ MULTIPART](https://github.com/microsoft/kiota/issues/3030), [TEXT](https://github.com/microsoft/kiota-serialization-text-python) | [Anonymous](https://github.com/microsoft/kiota-abstractions-python/blob/main/kiota_abstractions/authentication/anonymous_authentication_provider.py), [Azure](https://github.com/microsoft/kiota-authentication-azure-python) | [✔](https://github.com/microsoft/kiota-http-python) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/python) | +| Ruby | ✔ | [✔](https://github.com/microsoft/kiota-abstractions-ruby) | [❌ FORM](https://github.com/microsoft/kiota/issues/2077), [JSON](https://github.com/microsoft/kiota-serialization-json-ruby), [❌ MULTIPART](https://github.com/microsoft/kiota/issues/3032), [❌ TEXT](https://github.com/microsoft/kiota/issues/1049) | [Anonymous](https://github.com/microsoft/kiota-abstractions-ruby/blob/main/lib/microsoft_kiota_abstractions/authentication/anonymous_authentication_provider.rb), [✔️ OAuth2](https://github.com/microsoft/kiota-authentication-oauth-ruby) | [✔](https://github.com/microsoft/kiota-http-ruby)| [link](https://learn.microsoft.com/openapi/kiota/quickstarts/ruby) | | Shell | ✔ | (see CSHarp) + [✔](https://github.com/microsoft/kiota-cli-commons) | (see CSHarp) | (see CSharp) | (see CSharp) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/cli) | -| Swift | [▶](https://github.com/microsoft/kiota/issues/1449) | [✔](./abstractions/swift) | [❌ FORM](https://github.com/microsoft/kiota/issues/2076), [❌ JSON](https://github.com/microsoft/kiota/issues/1451), [❌ TEXT](https://github.com/microsoft/kiota/issues/1452) | [Anonymous](./abstractions/swift/Source/MicrosoftKiotaAbstractions/Authentication/AnonymousAuthenticationProvider.swift), [❌ Azure](https://github.com/microsoft/kiota/issues/1453) | [❌](https://github.com/microsoft/kiota/issues/1454)| | -| TypeScript/JavaScript | ✔ | [✔](https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions) | [FORM](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/form), [JSON](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/json), [TEXT](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/text) | [Anonymous](https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/authentication/anonymousAuthenticationProvider.ts), [API Key](https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/authentication/apiKeyAuthenticationProvider.ts), [Azure](https://github.com/microsoft/kiota-typescript/tree/main/packages/authentication/azure) | [✔](https://github.com/microsoft/kiota-typescript/tree/main/packages/http/fetch) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/typescript) | +| Swift | [▶](https://github.com/microsoft/kiota/issues/1449) | [✔](./abstractions/swift) | [❌ FORM](https://github.com/microsoft/kiota/issues/2076), [❌ JSON](https://github.com/microsoft/kiota/issues/1451), [❌ FORM](https://github.com/microsoft/kiota/issues/3033), [❌ TEXT](https://github.com/microsoft/kiota/issues/1452) | [Anonymous](./abstractions/swift/Source/MicrosoftKiotaAbstractions/Authentication/AnonymousAuthenticationProvider.swift), [❌ Azure](https://github.com/microsoft/kiota/issues/1453) | [❌](https://github.com/microsoft/kiota/issues/1454)| | +| TypeScript/JavaScript | ✔ | [✔](https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions) | [FORM](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/form), [JSON](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/json), [MULTIPART](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/multipart), [TEXT](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/text) | [Anonymous](https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/authentication/anonymousAuthenticationProvider.ts), [API Key](https://github.com/microsoft/kiota-typescript/blob/main/packages/abstractions/src/authentication/apiKeyAuthenticationProvider.ts), [Azure](https://github.com/microsoft/kiota-typescript/tree/main/packages/authentication/azure) | [✔](https://github.com/microsoft/kiota-typescript/tree/main/packages/http/fetch) | [link](https://learn.microsoft.com/openapi/kiota/quickstarts/typescript) | > Legend: ✔ -> in preview, ❌ -> not started, ▶ -> in progress. diff --git a/it/config.json b/it/config.json index 2de843bf67..a4b0f69fbd 100644 --- a/it/config.json +++ b/it/config.json @@ -259,6 +259,14 @@ { "Language": "ruby", "Rationale": "https://github.com/microsoft/kiota/issues/2484" + }, + { + "Language": "python", + "Rationale": "https://github.com/microsoft/kiota/issues/3030" + }, + { + "Language": "php", + "Rationale": "https://github.com/microsoft/kiota/issues/3029" } ] }, diff --git a/it/csharp/basic/basic.csproj b/it/csharp/basic/basic.csproj index 32ff9d2ecf..9559fd1297 100644 --- a/it/csharp/basic/basic.csproj +++ b/it/csharp/basic/basic.csproj @@ -10,21 +10,22 @@ - - + + - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + \ No newline at end of file diff --git a/it/csharp/dotnet.csproj b/it/csharp/dotnet.csproj index bb9fcfb583..ad5285585e 100644 --- a/it/csharp/dotnet.csproj +++ b/it/csharp/dotnet.csproj @@ -10,11 +10,12 @@ - + + diff --git a/it/go/basic/go.mod b/it/go/basic/go.mod index c82aa71635..0d5d557d62 100644 --- a/it/go/basic/go.mod +++ b/it/go/basic/go.mod @@ -3,23 +3,25 @@ module integrationtest go 1.20 require ( - github.com/microsoft/kiota-abstractions-go v0.19.0 + github.com/microsoft/kiota-abstractions-go v1.2.0 + github.com/microsoft/kiota-http-go v0.16.1 github.com/microsoft/kiota-serialization-form-go v0.9.0 - github.com/microsoft/kiota-serialization-json-go v0.9.0 + github.com/microsoft/kiota-serialization-json-go v1.0.4 + github.com/microsoft/kiota-serialization-multipart-go v1.0.0 github.com/microsoft/kiota-serialization-text-go v0.7.0 ) require ( 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.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/microsoft/kiota-http-go v0.16.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.8.2 // indirect + github.com/stretchr/testify v1.8.4 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect - go.opentelemetry.io/otel v1.14.0 // indirect - go.opentelemetry.io/otel/trace v1.14.0 // 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 gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/it/go/basic/go.sum b/it/go/basic/go.sum index 960d996142..358aa45b1c 100644 --- a/it/go/basic/go.sum +++ b/it/go/basic/go.sum @@ -1,11 +1,10 @@ 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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/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/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= @@ -13,33 +12,31 @@ 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/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/microsoft/kiota-abstractions-go v0.19.0 h1:R57UbZaIMdouccDpBMTNiwXljN/sOkeRSpXLtBAl2wg= -github.com/microsoft/kiota-abstractions-go v0.19.0/go.mod h1:0lbPErVO6Rj3HHpntNYW/OFmHhJJ1ewPdsi1xPxYIMc= +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-http-go v0.16.1 h1:5SZbSwHs14Xve5VMQHHz00lwL/kEg3H9rgESAUrXnvw= github.com/microsoft/kiota-http-go v0.16.1/go.mod h1:pKSaeSaBwh3Zadbnzw3kALEZbCZA1gq7A5PuxwVd/aU= github.com/microsoft/kiota-serialization-form-go v0.9.0 h1:ZMyvuxg7z1LmRWJOXr5QuJlwnD/tuNatb+k1KPURBFQ= github.com/microsoft/kiota-serialization-form-go v0.9.0/go.mod h1:FQqYzIrGX6KUoDOlg+DhDWoGaZoB8AicBYGOsBq0Dw4= -github.com/microsoft/kiota-serialization-json-go v0.9.0 h1:Em/YJb3eQGxcjNIPqKuaKrcuD0ib7tWXfaWccJrtIcc= -github.com/microsoft/kiota-serialization-json-go v0.9.0/go.mod h1:S7Ltu0/5hQjfeWmV9vQT5KYdFOsqHGdfMoP4Zo9Ctlw= +github.com/microsoft/kiota-serialization-json-go v1.0.4 h1:5TaISWwd2Me8clrK7SqNATo0tv9seOq59y4I5953egQ= +github.com/microsoft/kiota-serialization-json-go v1.0.4/go.mod h1:rM4+FsAY+9AEpBsBzkFFis+b/LZLlNKKewuLwK9Q6Mg= +github.com/microsoft/kiota-serialization-multipart-go v1.0.0 h1:3O5sb5Zj+moLBiJympbXNaeV07K0d46IfuEd5v9+pBs= +github.com/microsoft/kiota-serialization-multipart-go v1.0.0/go.mod h1:yauLeBTpANk4L03XD985akNysG24SnRJGaveZf+p4so= github.com/microsoft/kiota-serialization-text-go v0.7.0 h1:uayeq8fpDcZgL0zDyLkYZsH6zNnEXKgp+bRWfR5LcxA= github.com/microsoft/kiota-serialization-text-go v0.7.0/go.mod h1:2su1PTllHCMNkHugmvpYad+AKBXUUGoiNP3xOAJUL7w= 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.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +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.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= -go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= -go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= -go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= +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= 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.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/it/go/go.mod b/it/go/go.mod index 69bda3e53f..cce5813307 100644 --- a/it/go/go.mod +++ b/it/go/go.mod @@ -4,11 +4,12 @@ go 1.20 require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 - github.com/microsoft/kiota-abstractions-go v1.1.0 + github.com/microsoft/kiota-abstractions-go v1.2.0 github.com/microsoft/kiota-authentication-azure-go v1.0.0 github.com/microsoft/kiota-http-go v1.0.0 github.com/microsoft/kiota-serialization-form-go v1.0.0 - github.com/microsoft/kiota-serialization-json-go v1.0.3 + github.com/microsoft/kiota-serialization-json-go v1.0.4 + github.com/microsoft/kiota-serialization-multipart-go v1.0.0 github.com/microsoft/kiota-serialization-text-go v1.0.0 ) diff --git a/it/go/go.sum b/it/go/go.sum index 839c4f016a..2ae860c463 100644 --- a/it/go/go.sum +++ b/it/go/go.sum @@ -1,24 +1,17 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= 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/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= 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/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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/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= @@ -32,63 +25,46 @@ 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.1.0 h1:X1aKlsYCRs/0RSChr/fbq4j/+kxRzbSY5GeWhtHQNYI= -github.com/microsoft/kiota-abstractions-go v1.1.0/go.mod h1:RkxyZ5x87Njik7iVeQY9M2wtrrL1MJZcXiI/BxD/82g= +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-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-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.3 h1:U0VR3IPP8an9BHunuKykqpCIvM3FJzjMQy8tiit+FTk= -github.com/microsoft/kiota-serialization-json-go v1.0.3/go.mod h1:rM4+FsAY+9AEpBsBzkFFis+b/LZLlNKKewuLwK9Q6Mg= +github.com/microsoft/kiota-serialization-json-go v1.0.4 h1:5TaISWwd2Me8clrK7SqNATo0tv9seOq59y4I5953egQ= +github.com/microsoft/kiota-serialization-json-go v1.0.4/go.mod h1:rM4+FsAY+9AEpBsBzkFFis+b/LZLlNKKewuLwK9Q6Mg= +github.com/microsoft/kiota-serialization-multipart-go v1.0.0 h1:3O5sb5Zj+moLBiJympbXNaeV07K0d46IfuEd5v9+pBs= +github.com/microsoft/kiota-serialization-multipart-go v1.0.0/go.mod h1:yauLeBTpANk4L03XD985akNysG24SnRJGaveZf+p4so= github.com/microsoft/kiota-serialization-text-go v1.0.0 h1:XOaRhAXy+g8ZVpcq7x7a0jlETWnWrEum0RhmbYrTFnA= github.com/microsoft/kiota-serialization-text-go v1.0.0/go.mod h1:sM1/C6ecnQ7IquQOGUrUldaO5wj+9+v7G2W3sQ3fy6M= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= 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.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 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.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= -go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= 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.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= -go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= 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.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= 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.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/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.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= golang.org/x/text v0.10.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= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/it/java/basic/pom.xml b/it/java/basic/pom.xml index 825609a306..59d5dab9ea 100644 --- a/it/java/basic/pom.xml +++ b/it/java/basic/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.4.5 + 0.5.0 @@ -39,6 +39,11 @@ microsoft-kiota-serialization-form ${kiota-java.version} + + com.microsoft.kiota + microsoft-kiota-serialization-multipart + ${kiota-java.version} + com.microsoft.kiota microsoft-kiota-http-okHttp diff --git a/it/java/pom.xml b/it/java/pom.xml index cb82333deb..b8597a8a94 100644 --- a/it/java/pom.xml +++ b/it/java/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.4.5 + 0.5.0 @@ -39,6 +39,11 @@ microsoft-kiota-serialization-form ${kiota-java.version} + + com.microsoft.kiota + microsoft-kiota-serialization-multipart + ${kiota-java.version} + com.google.code.findbugs jsr305 diff --git a/it/typescript/package-lock.json b/it/typescript/package-lock.json index 44c7237696..43a66a405c 100644 --- a/it/typescript/package-lock.json +++ b/it/typescript/package-lock.json @@ -15,6 +15,7 @@ "@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.23", "@microsoft/kiota-serialization-form": "^1.0.0-preview.13", "@microsoft/kiota-serialization-json": "^1.0.0-preview.22", + "@microsoft/kiota-serialization-multipart": "^1.0.0-preview.2", "@microsoft/kiota-serialization-text": "^1.0.0-preview.21", "express": "^4.18.2", "node-fetch": "^2.6.9" @@ -662,9 +663,9 @@ "dev": true }, "node_modules/@microsoft/kiota-abstractions": { - "version": "1.0.0-preview.24", - "resolved": "https://registry.npmjs.org/@microsoft/kiota-abstractions/-/kiota-abstractions-1.0.0-preview.24.tgz", - "integrity": "sha512-O5s8f/bpSGvl2WeEhLOV2O7eK5qMc00Wr52FUl7Azi4iSBgNgVsJA/S0Fk+q/pYOMXfrNKR5h0KM4UALOYOa7w==", + "version": "1.0.0-preview.26", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-abstractions/-/kiota-abstractions-1.0.0-preview.26.tgz", + "integrity": "sha512-+8s1TvvJrWLHDjtZeKw9Han3kaKKOuGQ8PSC0KRno/Uj1j1cSGrsYF8kUOsnjIFvC4u5rPRFLkt+0iUNJFRJJA==", "dependencies": { "@opentelemetry/api": "^1.2.0", "guid-typescript": "^1.0.9", @@ -683,22 +684,22 @@ } }, "node_modules/@microsoft/kiota-authentication-azure": { - "version": "1.0.0-preview.19", - "resolved": "https://registry.npmjs.org/@microsoft/kiota-authentication-azure/-/kiota-authentication-azure-1.0.0-preview.19.tgz", - "integrity": "sha512-1eCsQ3g4NBOFhMAfoYky2urdkKrwL/iEp1fTPYdB3eXVqsMlrVzRzkt3OjxtfwuHSXgzSsULwUumobOfxw4ZRQ==", + "version": "1.0.0-preview.21", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-authentication-azure/-/kiota-authentication-azure-1.0.0-preview.21.tgz", + "integrity": "sha512-CpmHMVsSRgFCpo4eeikcuNjqqugG46DR3oS15PVpai9dG5N3AbaHlDBLUfhP1Jf3buomSAM2fBgzhmvmNw9/UQ==", "dependencies": { "@azure/core-auth": "^1.3.2", - "@microsoft/kiota-abstractions": "^1.0.0-preview.24", + "@microsoft/kiota-abstractions": "^1.0.0-preview.26", "@opentelemetry/api": "^1.2.0", "tslib": "^2.3.1" } }, "node_modules/@microsoft/kiota-http-fetchlibrary": { - "version": "1.0.0-preview.23", - "resolved": "https://registry.npmjs.org/@microsoft/kiota-http-fetchlibrary/-/kiota-http-fetchlibrary-1.0.0-preview.23.tgz", - "integrity": "sha512-301vDEUo1DXmMc/n3ALmxkJ4NGYADTze4c6wsHkOpwHBIfouefwDJSYBi2WAxv4t6S9GK0QOIEe/m1fMI3gWJA==", + "version": "1.0.0-preview.25", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-http-fetchlibrary/-/kiota-http-fetchlibrary-1.0.0-preview.25.tgz", + "integrity": "sha512-rJRvZpBu83zP1x4dKJ9O0Ms7bzOx322EarV9hhzOkQ7ZIhyP5SYyQsezvJz5nb/+QzdsVllkbQMyENn/JquBAg==", "dependencies": { - "@microsoft/kiota-abstractions": "^1.0.0-preview.24", + "@microsoft/kiota-abstractions": "^1.0.0-preview.26", "@opentelemetry/api": "^1.2.0", "guid-typescript": "^1.0.9", "node-fetch": "^2.6.5", @@ -706,31 +707,41 @@ } }, "node_modules/@microsoft/kiota-serialization-form": { - "version": "1.0.0-preview.13", - "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-form/-/kiota-serialization-form-1.0.0-preview.13.tgz", - "integrity": "sha512-c16YbF48qIKdR9CvIqRvq74lOc9ExHXByE7SztabOBuDh49GEUub/+LZ0rs99gq0rFyiqzyCF1XWPqWe6KDGpw==", + "version": "1.0.0-preview.15", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-form/-/kiota-serialization-form-1.0.0-preview.15.tgz", + "integrity": "sha512-mEMqcg4P4gL56FPBbaPeO0fZustiaKhkBt9siBDxmV/cqK6rxEhKMFVsHo18sIWZh3I60nG+VCObKdeXFpXAlw==", "dependencies": { - "@microsoft/kiota-abstractions": "^1.0.0-preview.24", + "@microsoft/kiota-abstractions": "^1.0.0-preview.26", "guid-typescript": "^1.0.9", "tslib": "^2.3.1" } }, "node_modules/@microsoft/kiota-serialization-json": { - "version": "1.0.0-preview.22", - "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-json/-/kiota-serialization-json-1.0.0-preview.22.tgz", - "integrity": "sha512-XziuBnjawk3aKfTP136bsU5Q/a8YcOq/JVNNnh3JFjZA6CAcDxqAZ24DPSSy5BULySt45pVHHUxsSolTY4ra5Q==", + "version": "1.0.0-preview.24", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-json/-/kiota-serialization-json-1.0.0-preview.24.tgz", + "integrity": "sha512-fnU89kafYq6if9oqMshHsL8rucDN+Xr2Cow5uWQauhfDLFrfwGaJK0Kcl9svHFwQ8CYJIUeHPNSu5WZB89LaCw==", + "dependencies": { + "@microsoft/kiota-abstractions": "^1.0.0-preview.26", + "guid-typescript": "^1.0.9", + "tslib": "^2.3.1" + } + }, + "node_modules/@microsoft/kiota-serialization-multipart": { + "version": "1.0.0-preview.3", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-multipart/-/kiota-serialization-multipart-1.0.0-preview.3.tgz", + "integrity": "sha512-w1cAy6twf11/tuSNNt4U+FgMueeBzGxpoJsaQl0p2D22FwT71/itIwhIZMwUjUu/Tejs9nCW1UdAy3AHjWuuWw==", "dependencies": { - "@microsoft/kiota-abstractions": "^1.0.0-preview.24", + "@microsoft/kiota-abstractions": "^1.0.0-preview.26", "guid-typescript": "^1.0.9", "tslib": "^2.3.1" } }, "node_modules/@microsoft/kiota-serialization-text": { - "version": "1.0.0-preview.21", - "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-text/-/kiota-serialization-text-1.0.0-preview.21.tgz", - "integrity": "sha512-X6eb8OTfH589ih4DetYLg73IITVntKe6eNhFkT6fWH2/EwaHJhK3oXEm6eXqRuCYuDYnZSjF0yRC2mtZdH0wPQ==", + "version": "1.0.0-preview.23", + "resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-text/-/kiota-serialization-text-1.0.0-preview.23.tgz", + "integrity": "sha512-4mu2q6qubcPBXwcslzyHxAGTfoAUnnm3/dwWMQeLKxuHEWopuaEW3OGNdpXpV4ON303OFO2gVCx6pYhjktZ32A==", "dependencies": { - "@microsoft/kiota-abstractions": "^1.0.0-preview.24", + "@microsoft/kiota-abstractions": "^1.0.0-preview.26", "guid-typescript": "^1.0.9", "tslib": "^2.3.1" } @@ -1682,9 +1693,9 @@ "dev": true }, "node_modules/fast-glob": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.0.tgz", - "integrity": "sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -3001,9 +3012,9 @@ } }, "node_modules/tslib": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz", - "integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==" + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", + "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==" }, "node_modules/type-check": { "version": "0.4.0", diff --git a/it/typescript/package.json b/it/typescript/package.json index 1c1b24e148..fda8b27ba0 100644 --- a/it/typescript/package.json +++ b/it/typescript/package.json @@ -36,6 +36,7 @@ "@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.23", "@microsoft/kiota-serialization-form": "^1.0.0-preview.13", "@microsoft/kiota-serialization-json": "^1.0.0-preview.22", + "@microsoft/kiota-serialization-multipart": "^1.0.0-preview.2", "@microsoft/kiota-serialization-text": "^1.0.0-preview.21", "express": "^4.18.2", "node-fetch": "^2.6.9" diff --git a/src/Kiota.Builder/Configuration/GenerationConfiguration.cs b/src/Kiota.Builder/Configuration/GenerationConfiguration.cs index b78c46f4e6..8849f05924 100644 --- a/src/Kiota.Builder/Configuration/GenerationConfiguration.cs +++ b/src/Kiota.Builder/Configuration/GenerationConfiguration.cs @@ -33,15 +33,16 @@ public bool UsesBackingStore public HashSet Serializers { get; set; - } = new(2, StringComparer.OrdinalIgnoreCase){ + } = new(4, StringComparer.OrdinalIgnoreCase){ "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory", "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory", "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory", + "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory" }; public HashSet Deserializers { get; set; - } = new(2, StringComparer.OrdinalIgnoreCase) { + } = new(3, StringComparer.OrdinalIgnoreCase) { "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory", "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory", "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory", @@ -85,10 +86,11 @@ public bool CleanOutput public HashSet StructuredMimeTypes { get; set; - } = new(5, StringComparer.OrdinalIgnoreCase) { + } = new(4, StringComparer.OrdinalIgnoreCase) { "application/json", "text/plain", "application/x-www-form-urlencoded", + "multipart/form-data", }; public HashSet IncludePatterns { get; set; } = new(0, StringComparer.OrdinalIgnoreCase); public HashSet ExcludePatterns { get; set; } = new(0, StringComparer.OrdinalIgnoreCase); diff --git a/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs b/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs index a6f38186fe..20c5106b98 100644 --- a/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs +++ b/src/Kiota.Builder/Extensions/OpenApiOperationExtensions.cs @@ -33,6 +33,12 @@ internal static IEnumerable GetResponseSchemas(this OpenApiOperat return operation.RequestBody?.Content .GetValidSchemas(structuredMimeTypes).FirstOrDefault(); } + private static readonly HashSet multipartMimeTypes = new(1, StringComparer.OrdinalIgnoreCase) { "multipart/form-data" }; + public static bool IsMultipartFormDataSchema(this IDictionary source, HashSet structuredMimeTypes) + { + return source.GetValidSchemas(structuredMimeTypes).FirstOrDefault() is OpenApiSchema schema && + source.GetValidSchemas(multipartMimeTypes).FirstOrDefault() == schema; + } public static IEnumerable GetValidSchemas(this IDictionary source, HashSet structuredMimeTypes) { if (!(structuredMimeTypes?.Any() ?? false)) diff --git a/src/Kiota.Builder/Kiota.Builder.csproj b/src/Kiota.Builder/Kiota.Builder.csproj index 1306f00efe..1ccfb4591f 100644 --- a/src/Kiota.Builder/Kiota.Builder.csproj +++ b/src/Kiota.Builder/Kiota.Builder.csproj @@ -43,10 +43,11 @@ all - + + diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index bf8546820d..4a4d4d8979 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -1305,12 +1305,32 @@ private static void AddRequestConfigurationProperties(CodeClass? parameterClass, }); } + private readonly ConcurrentDictionary multipartPropertiesModels = new(); private void AddRequestBuilderMethodParameters(OpenApiUrlTreeNode currentNode, OperationType operationType, OpenApiOperation operation, CodeClass requestConfigClass, CodeMethod method) { if (operation.GetRequestSchema(config.StructuredMimeTypes) is OpenApiSchema requestBodySchema) { - var requestBodyType = CreateModelDeclarations(currentNode, requestBodySchema, operation, method, $"{operationType}RequestBody", isRequestBody: true) ?? - throw new InvalidSchemaException(); + CodeTypeBase requestBodyType; + if (operation.RequestBody.Content.IsMultipartFormDataSchema(config.StructuredMimeTypes)) + { + requestBodyType = new CodeType + { + Name = "MultipartBody", + IsExternal = true, + }; + var mediaType = operation.RequestBody.Content.First(x => x.Value.Schema == requestBodySchema).Value; + foreach (var encodingEntry in mediaType.Encoding + .Where(x => !string.IsNullOrEmpty(x.Value.ContentType) && + config.StructuredMimeTypes.Contains(x.Value.ContentType.Split(';', StringSplitOptions.RemoveEmptyEntries)[0]))) + { + if (CreateModelDeclarations(currentNode, requestBodySchema.Properties[encodingEntry.Key], operation, method, $"{operationType}RequestBody", isRequestBody: true) is CodeType propertyType && + propertyType.TypeDefinition is not null) + multipartPropertiesModels.TryAdd(propertyType.TypeDefinition, true); + } + } + else + requestBodyType = CreateModelDeclarations(currentNode, requestBodySchema, operation, method, $"{operationType}RequestBody", isRequestBody: true) ?? + throw new InvalidSchemaException(); method.AddParameter(new CodeParameter { Name = "body", @@ -1711,7 +1731,7 @@ private void TrimInheritedModels() { if (modelsNamespace is null || rootNamespace is null || modelsNamespace.Parent is not CodeNamespace clientNamespace) return; var reusableModels = GetAllModels(modelsNamespace).ToArray();//to avoid multiple enumerations - var modelsDirectlyInUse = GetTypeDefinitionsInNamespace(rootNamespace).ToArray(); + var modelsDirectlyInUse = GetTypeDefinitionsInNamespace(rootNamespace).Union(multipartPropertiesModels.Keys).ToArray(); var classesDirectlyInUse = modelsDirectlyInUse.OfType().ToHashSet(); var allModelClassesIndex = GetDerivationIndex(GetAllModels(clientNamespace).OfType()); var derivedClassesInUse = GetDerivedDefinitions(allModelClassesIndex, classesDirectlyInUse.ToArray()); @@ -2105,5 +2125,6 @@ private void CleanUpInternalState() foreach (var lifecycle in classLifecycles.Values) lifecycle.Dispose(); classLifecycles.Clear(); + multipartPropertiesModels.Clear(); } } diff --git a/src/Kiota.Builder/Refiners/CSharpRefiner.cs b/src/Kiota.Builder/Refiners/CSharpRefiner.cs index 755afc5eaa..9c433b9962 100644 --- a/src/Kiota.Builder/Refiners/CSharpRefiner.cs +++ b/src/Kiota.Builder/Refiners/CSharpRefiner.cs @@ -181,7 +181,10 @@ protected static void MakeEnumPropertiesNullable(CodeElement currentElement) "System.Runtime.Serialization", "EnumMemberAttribute"), new (static x => x is IDeprecableElement element && element.Deprecation is not null && element.Deprecation.IsDeprecated, "System", "ObsoleteAttribute"), + new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator) && method.Parameters.Any(static y => y.IsOfKind(CodeParameterKind.RequestBody) && y.Type.Name.Equals(MultipartBodyClassName, StringComparison.OrdinalIgnoreCase)), + AbstractionsNamespaceName, MultipartBodyClassName), }; + private const string MultipartBodyClassName = "MultipartBody"; protected static void CapitalizeNamespacesFirstLetters(CodeElement current) { if (current is CodeNamespace currentNamespace) diff --git a/src/Kiota.Builder/Refiners/CSharpReservedTypesProvider.cs b/src/Kiota.Builder/Refiners/CSharpReservedTypesProvider.cs index a7c79635ac..a34b09effb 100644 --- a/src/Kiota.Builder/Refiners/CSharpReservedTypesProvider.cs +++ b/src/Kiota.Builder/Refiners/CSharpReservedTypesProvider.cs @@ -130,6 +130,7 @@ public class CSharpReservedTypesProvider : IReservedNamesProvider "MTAThreadAttribute", "MulticastDelegate", "MulticastNotSupportedException", + "MultipartBody", "NonSerializedAttribute", "NotFiniteNumberException", "NotImplementedException", diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 32dd1344ac..c7a51d4dc8 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -128,6 +128,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance "github.com/microsoft/kiota-serialization-json-go.JsonSerializationWriterFactory", "github.com/microsoft/kiota-serialization-text-go.TextSerializationWriterFactory", "github.com/microsoft/kiota-serialization-form-go.FormSerializationWriterFactory", + "github.com/microsoft/kiota-serialization-multipart-go.MultipartSerializationWriterFactory", }); ReplaceDefaultDeserializationModules( generatedCode, @@ -506,9 +507,9 @@ private static void AddErrorImportForEnums(CodeElement currentElement) }; private static readonly AdditionalUsingEvaluator[] defaultUsingEvaluators = { new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.RequestAdapter), - "github.com/microsoft/kiota-abstractions-go", "RequestAdapter"), + AbstractionsNamespaceName, "RequestAdapter"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "github.com/microsoft/kiota-abstractions-go", "RequestInformation", "HttpMethod", "RequestOption"), + AbstractionsNamespaceName, "RequestInformation", "HttpMethod", "RequestOption"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Constructor) && method.Parameters.Any(x => x.IsOfKind(CodeParameterKind.Path) && !typeToSkipStrConv.Contains(x.Type.Name)), @@ -537,12 +538,16 @@ x.Type is CodeType pType && new (static x => x is CodeClass @class && @class.OriginalComposedType is CodeIntersectionType intersectionType && intersectionType.Types.Any(static y => !y.IsExternal) && intersectionType.DiscriminatorInformation.HasBasicDiscriminatorInformation, "github.com/microsoft/kiota-abstractions-go/serialization", "MergeDeserializersForIntersectionWrapper"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Headers), - "github.com/microsoft/kiota-abstractions-go", "RequestHeaders"), + AbstractionsNamespaceName, "RequestHeaders"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.BackingStore), "github.com/microsoft/kiota-abstractions-go/store","BackingStore"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor) && method.Parameters.Any(y => y.IsOfKind(CodeParameterKind.BackingStore)), "github.com/microsoft/kiota-abstractions-go/store", "BackingStoreFactory"), + new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator) && method.Parameters.Any(static y => y.IsOfKind(CodeParameterKind.RequestBody) && y.Type.Name.Equals(MultipartBodyClassName, StringComparison.OrdinalIgnoreCase)), + AbstractionsNamespaceName, MultipartBodyClassName), }; + private const string MultipartBodyClassName = "MultipartBody"; + private const string AbstractionsNamespaceName = "github.com/microsoft/kiota-abstractions-go"; private void CorrectImplements(ProprietableBlockDeclaration block) { @@ -552,9 +557,12 @@ private void CorrectImplements(ProprietableBlockDeclaration block) private static void CorrectMethodType(CodeMethod currentMethod) { var parentClass = currentMethod.Parent as CodeClass; - if (currentMethod.IsOfKind(CodeMethodKind.RequestGenerator)) + if (currentMethod.IsOfKind(CodeMethodKind.RequestGenerator, CodeMethodKind.RequestExecutor)) { - currentMethod.ReturnType.IsNullable = true; + if (currentMethod.IsOfKind(CodeMethodKind.RequestGenerator)) + currentMethod.ReturnType.IsNullable = true; + if (currentMethod.Parameters.OfKind(CodeParameterKind.RequestBody) is CodeParameter bodyParam && bodyParam.Type.Name.Equals(MultipartBodyClassName, StringComparison.OrdinalIgnoreCase)) + bodyParam.Type.IsNullable = false; } else if (currentMethod.IsOfKind(CodeMethodKind.Serializer)) currentMethod.Parameters.Where(static x => x.Type.Name.Equals("ISerializationWriter", StringComparison.Ordinal)).ToList().ForEach(x => x.Type.Name = "SerializationWriter"); @@ -591,7 +599,7 @@ private static void CorrectMethodType(CodeMethod currentMethod) currentMethod.ReturnType = new CodeType { Name = "Parsable", IsNullable = false, IsExternal = true }; } CorrectCoreTypes(parentClass, DateTypesReplacements, currentMethod.Parameters - .Select(x => x.Type) + .Select(static x => x.Type) .Union(new[] { currentMethod.ReturnType }) .ToArray()); } diff --git a/src/Kiota.Builder/Refiners/GoReservedNamesProvider.cs b/src/Kiota.Builder/Refiners/GoReservedNamesProvider.cs index 3ce90d28fd..bf7b831b08 100644 --- a/src/Kiota.Builder/Refiners/GoReservedNamesProvider.cs +++ b/src/Kiota.Builder/Refiners/GoReservedNamesProvider.cs @@ -31,7 +31,8 @@ public class GoReservedNamesProvider : IReservedNamesProvider "type", "var", "vendor", // cannot be used as a package name - "BaseRequestBuilder" + "BaseRequestBuilder", + "MultipartBody", }); public HashSet ReservedNames => _reservedNames.Value; } diff --git a/src/Kiota.Builder/Refiners/JavaRefiner.cs b/src/Kiota.Builder/Refiners/JavaRefiner.cs index da187ca04b..5a244e667a 100644 --- a/src/Kiota.Builder/Refiners/JavaRefiner.cs +++ b/src/Kiota.Builder/Refiners/JavaRefiner.cs @@ -105,6 +105,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance $"{SerializationNamespaceName}.JsonSerializationWriterFactory", $"{SerializationNamespaceName}.TextSerializationWriterFactory", $"{SerializationNamespaceName}.FormSerializationWriterFactory", + $"{SerializationNamespaceName}.MultipartSerializationWriterFactory", } ); ReplaceDefaultDeserializationModules( @@ -242,7 +243,10 @@ private static void AddEnumSetImport(CodeElement currentElement) AbstractionsNamespaceName, "QueryParameter"), new (static x => x is CodeClass @class && @class.OriginalComposedType is CodeIntersectionType intersectionType && intersectionType.Types.Any(static y => !y.IsExternal), SerializationNamespaceName, "ParseNodeHelper"), + new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator) && method.Parameters.Any(static y => y.IsOfKind(CodeParameterKind.RequestBody) && y.Type.Name.Equals(MultipartBodyClassName, StringComparison.OrdinalIgnoreCase)), + AbstractionsNamespaceName, MultipartBodyClassName) }; + private const string MultipartBodyClassName = "MultipartBody"; private static void CorrectPropertyType(CodeProperty currentProperty) { if (currentProperty.IsOfKind(CodePropertyKind.RequestAdapter)) diff --git a/src/Kiota.Builder/Refiners/JavaReservedNamesProvider.cs b/src/Kiota.Builder/Refiners/JavaReservedNamesProvider.cs index 96d7c45688..9b80829986 100644 --- a/src/Kiota.Builder/Refiners/JavaReservedNamesProvider.cs +++ b/src/Kiota.Builder/Refiners/JavaReservedNamesProvider.cs @@ -63,6 +63,7 @@ public class JavaReservedNamesProvider : IReservedNamesProvider "wait", "while", "BaseRequestBuilder", + "MultipartBody", }); public HashSet ReservedNames => _reservedNames.Value; } diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index 3cd51b5267..ddd8fd1b09 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -78,6 +78,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance "@microsoft/kiota-serialization-json.JsonSerializationWriterFactory", "@microsoft/kiota-serialization-text.TextSerializationWriterFactory", "@microsoft/kiota-serialization-form.FormSerializationWriterFactory", + "@microsoft/kiota-serialization-multipart.MultipartSerializationWriterFactory", } ); ReplaceDefaultDeserializationModules( @@ -214,8 +215,11 @@ currentInterface.StartBlock is InterfaceDeclaration interfaceDeclaration && method.Parameters.Any(y => y.IsOfKind(CodeParameterKind.BackingStore)), AbstractionsPackageName, "BackingStoreFactory", "BackingStoreFactorySingleton"), new (x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.BackingStore), - AbstractionsPackageName, "BackingStore", "BackedModel", "BackingStoreFactorySingleton" ), + AbstractionsPackageName, "BackingStore", "BackedModel", "BackingStoreFactorySingleton"), + new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator) && method.Parameters.Any(static y => y.IsOfKind(CodeParameterKind.RequestBody) && y.Type.Name.Equals(MultipartBodyClassName, StringComparison.OrdinalIgnoreCase)), + AbstractionsPackageName, MultipartBodyClassName, $"serialize{MultipartBodyClassName}") }; + private const string MultipartBodyClassName = "MultipartBody"; private static void CorrectImplements(ProprietableBlockDeclaration block) { block.Implements.Where(x => "IAdditionalDataHolder".Equals(x.Name, StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => x.Name = x.Name[1..]); // skipping the I @@ -248,8 +252,8 @@ private static void CorrectMethodType(CodeMethod currentMethod) { if (currentMethod.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator)) { - if (currentMethod.IsOfKind(CodeMethodKind.RequestExecutor)) - currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.ResponseHandler) && x.Type.Name.StartsWith("i", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => x.Type.Name = x.Type.Name[1..]); + if (currentMethod.Parameters.OfKind(CodeParameterKind.RequestBody) is CodeParameter requestBodyParam) + requestBodyParam.Type.IsNullable = false; } else if (currentMethod.IsOfKind(CodeMethodKind.Serializer)) currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Serializer) && x.Type.Name.StartsWith("i", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => x.Type.Name = x.Type.Name[1..]); diff --git a/src/Kiota.Builder/Refiners/TypeScriptReservedNamesProvider.cs b/src/Kiota.Builder/Refiners/TypeScriptReservedNamesProvider.cs index fbb6cd2310..ccb06a9b24 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptReservedNamesProvider.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptReservedNamesProvider.cs @@ -43,6 +43,7 @@ public class TypeScriptReservedNamesProvider : IReservedNamesProvider "while", "with", "BaseRequestBuilder", + "MultipartBody" }); public HashSet ReservedNames => _reservedNames.Value; } diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index d29a311361..eccfccccdb 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -415,7 +415,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req 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) + 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});"); diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs index 3215f12244..60bb9e3734 100644 --- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs @@ -807,7 +807,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req 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)) + 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) { diff --git a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs index 84b5f4e90f..0e5eb70874 100644 --- a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs @@ -539,7 +539,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req 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) + else if (requestParams.requestBody.Type is CodeType bodyType && (bodyType.TypeDefinition is CodeClass || bodyType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) writer.WriteLine($"{RequestInfoVarName}.setContentFromParsable({requestAdapterProperty.Name.ToFirstCharacterLowerCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name}{toArrayPostfix});"); else writer.WriteLine($"{RequestInfoVarName}.setContentFromScalar{collectionPostfix}({requestAdapterProperty.Name.ToFirstCharacterLowerCase()}, \"{codeElement.RequestBodyContentType}\", {requestParams.requestBody.Name}{toArrayPostfix});"); diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs index dce365fcf8..3aa367477e 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs @@ -149,7 +149,7 @@ private void WritePropertySerializer(string modelParamName, CodeProperty codePro private string GetSerializationMethodName(CodeTypeBase propType) { var propertyType = conventions.TranslateType(propType); - if (!string.IsNullOrEmpty(propertyType) && propType is CodeType currentType && GetSerializationMethodNameForCodeType(currentType, propertyType) is string result && !String.IsNullOrWhiteSpace(result)) + if (!string.IsNullOrEmpty(propertyType) && propType is CodeType currentType && GetSerializationMethodNameForCodeType(currentType, propertyType) is string result && !string.IsNullOrWhiteSpace(result)) { return result; } @@ -160,10 +160,12 @@ private string GetSerializationMethodName(CodeTypeBase propType) }; } - private static string? GetSerializationMethodNameForCodeType(CodeType propType, string propertyType) + private string? GetSerializationMethodNameForCodeType(CodeType propType, string propertyType) { if (propType.TypeDefinition is CodeEnum currentEnum) return $"writeEnumValue<{currentEnum.Name.ToFirstCharacterUpperCase()}>"; + else if (conventions.StreamTypeName.Equals(propertyType, StringComparison.OrdinalIgnoreCase)) + return "writeByteArrayValue"; else if (propType.CollectionKind != CodeTypeBase.CodeTypeCollectionKind.None) { if (propType.TypeDefinition == null) @@ -206,6 +208,8 @@ private string GetDeserializationMethodName(CodeTypeBase propType, CodeFunction { if (currentType.TypeDefinition is CodeEnum currentEnum) return $"{(currentEnum.Flags || isCollection ? "getCollectionOfEnumValues" : "getEnumValue")}<{currentEnum.Name.ToFirstCharacterUpperCase()}>({propertyType.ToFirstCharacterUpperCase()})"; + else if (conventions.StreamTypeName.Equals(propertyType, StringComparison.OrdinalIgnoreCase)) + return "getByteArrayValue"; else if (isCollection) if (currentType.TypeDefinition == null) return $"getCollectionOfPrimitiveValues<{propertyType}>()"; diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs index 7b5fe95c98..79b93e5f81 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs @@ -101,9 +101,12 @@ internal static void WriteDefensiveStatements(CodeMethod codeElement, LanguageWr { if (codeElement.IsOfKind(CodeMethodKind.Setter)) return; + var isRequestExecutor = codeElement.IsOfKind(CodeMethodKind.RequestExecutor); + foreach (var parameter in codeElement.Parameters - .Where(static x => !x.Optional && !x.IsOfKind(CodeParameterKind.RequestAdapter, CodeParameterKind.PathParameters)) - .OrderBy(static x => x.Name)) + .Where(x => !x.Optional && !x.IsOfKind(CodeParameterKind.RequestAdapter, CodeParameterKind.PathParameters) && + !(isRequestExecutor && x.IsOfKind(CodeParameterKind.RequestBody))) + .OrderBy(static x => x.Name, StringComparer.OrdinalIgnoreCase)) { var parameterName = parameter.Name.ToFirstCharacterLowerCase(); writer.WriteLine($"if(!{parameterName}) throw new Error(\"{parameterName} cannot be undefined\");"); @@ -378,10 +381,10 @@ private void ComposeContentInRequestGeneratorBody(CodeParameter requestBody, Cod } var spreadOperator = requestBody.Type.AllTypes.First().IsCollection ? "..." : string.Empty; - if (requestBody.Type is CodeType currentType && currentType.TypeDefinition is CodeInterface codeInterface) + if (requestBody.Type is CodeType currentType && (currentType.TypeDefinition is CodeInterface || currentType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase))) { - var serializerName = $"serialize{codeInterface.Name.ToFirstCharacterUpperCase()}"; - writer.WriteLine($"{RequestInfoVarName}.setContentFromParsable(this.{requestAdapterProperty.Name.ToFirstCharacterLowerCase()}, \"{contentType}\", body as any, {serializerName});"); + var serializerName = $"serialize{currentType.Name.ToFirstCharacterUpperCase()}"; + writer.WriteLine($"{RequestInfoVarName}.setContentFromParsable(this.{requestAdapterProperty.Name.ToFirstCharacterLowerCase()}, \"{contentType}\", {requestBody.Name}, {serializerName});"); } else { diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index 04fe9163c3..786115e37f 100644 --- a/src/kiota/appsettings.json +++ b/src/kiota/appsettings.json @@ -1,8 +1,6 @@ { "Generation": { - "IgnoredRequestContentTypes": [ - "multipart/form-data" - ], + "IgnoredRequestContentTypes": [], "MaxDegreeOfParallelism": -1 }, "Search": { @@ -50,6 +48,10 @@ { "Name": "Microsoft.Kiota.Serialization.Text", "Version": "1.0.1" + }, + { + "Name": "Microsoft.Kiota.Serialization.Multipart", + "Version": "1.0.0" } ], "DependencyInstallCommand": "dotnet add package {0} --version {1}" @@ -80,6 +82,10 @@ { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-text", "Version": "0.4.5" + }, + { + "Name": "com.microsoft.kiota:microsoft-kiota-serialization-multipart", + "Version": "0.5.0" } ], "DependencyInstallCommand": "{0}:{1}" @@ -110,6 +116,10 @@ { "Name": "github.com/microsoft/kiota-serialization-text-go", "Version": "v1.0.0" + }, + { + "Name": "github.com/microsoft/kiota-serialization-multipart-go", + "Version": "v1.0.0" } ], "DependencyInstallCommand": "go get {0}@{1}" @@ -140,6 +150,10 @@ { "Name": "@microsoft/kiota-serialization-text", "Version": "1.0.0-preview.19" + }, + { + "Name": "@microsoft/kiota-serialization-multipart", + "Version": "1.0.0-preview.2" } ], "DependencyInstallCommand": "npm install {0}@{1} -S" diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 6eb2d8beda..b4b8185ace 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -6230,4 +6230,70 @@ public async Task CleanupSymbolNameDoesNotCauseNameConflictsInQueryParameters() Assert.Equal("select", select.WireName); Assert.Equal("int64", select.Type.Name); } + [Fact] + public async Task SupportsMultiPartFormAsRequestBody() + { + var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); + await using var fs = await GetDocumentStream(@"openapi: 3.0.1 +info: + title: Example + description: Example + version: 1.0.1 +servers: + - url: https://example.org +paths: + /directoryObject: + post: + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + id: + type: string + format: uuid + address: + $ref: '#/components/schemas/address' + profileImage: + type: string + format: binary + encoding: + id: + contentType: text/plain + address: + contentType: application/json + profileImage: + contentType: image/png + responses: + '204': + content: + application/json: + schema: + type: string +components: + schemas: + address: + type: object + properties: + street: + type: string + city: + type: string"); + var mockLogger = new Mock>(); + var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", OpenAPIFilePath = tempFilePath, IncludeAdditionalData = false }, _httpClient); + var document = await builder.CreateOpenApiDocumentAsync(fs); + var node = builder.CreateUriSpace(document); + var codeModel = builder.CreateSourceModel(node); + Assert.NotNull(codeModel); + var rbClass = codeModel.FindChildByName("directoryObjectRequestBuilder"); + Assert.NotNull(rbClass); + var postMethod = rbClass.FindChildByName("Post", false); + Assert.NotNull(postMethod); + var bodyParameter = postMethod.Parameters.FirstOrDefault(x => x.IsOfKind(CodeParameterKind.RequestBody)); + Assert.NotNull(bodyParameter); + Assert.Equal("MultipartBody", bodyParameter.Type.Name, StringComparer.OrdinalIgnoreCase); + var addressClass = codeModel.FindChildByName("Address"); + Assert.NotNull(addressClass); + } } diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs index 454efa2bde..ba00566b8d 100644 --- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs @@ -422,12 +422,6 @@ private void AddRequestBodyParameters(bool useComplexTypeForBody = false) Optional = true, }); method.AddParameter(new CodeParameter - { - Name = "r", - Kind = CodeParameterKind.ResponseHandler, - Type = stringType, - }); - method.AddParameter(new CodeParameter { Name = "c", Kind = CodeParameterKind.Cancellation, @@ -487,6 +481,20 @@ public void WritesRequestExecutorBody() AssertExtensions.CurlyBracesAreClosed(result, 1); } [Fact] + public void WritesRequestGeneratorBodyForMultipart() + { + setup(); + method.Kind = CodeMethodKind.RequestGenerator; + method.HttpMethod = HttpMethod.Post; + AddRequestProperties(); + AddRequestBodyParameters(); + method.Parameters.First(static x => x.IsOfKind(CodeParameterKind.RequestBody)).Type = new CodeType { Name = "MultipartBody", IsExternal = true }; + writer.Write(method); + var result = tw.ToString(); + Assert.Contains("SetContentFromParsable", result); + AssertExtensions.CurlyBracesAreClosed(result, 1); + } + [Fact] public void WritesRequestExecutorBodyForCollection() { setup(); diff --git a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs index 566c6d2579..71cd25b756 100644 --- a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs @@ -617,12 +617,6 @@ private void AddRequestBodyParameters(CodeMethod target = default, bool useCompl }).First(), } : stringType, }); - target.AddParameter(new CodeParameter - { - Name = "r", - Kind = CodeParameterKind.ResponseHandler, - Type = stringType, - }); } [Fact] public void WritesNullableVoidTypeForExecutor() @@ -663,6 +657,20 @@ public void WritesRequestBodiesThrowOnNullHttpMethod() Assert.Throws(() => writer.Write(method)); } [Fact] + public void WritesRequestGeneratorBodyForMultipart() + { + setup(); + method.Kind = CodeMethodKind.RequestGenerator; + method.HttpMethod = HttpMethod.Post; + AddRequestProperties(); + AddRequestBodyParameters(); + method.Parameters.First(static x => x.IsOfKind(CodeParameterKind.RequestBody)).Type = new CodeType { Name = "MultipartBody", IsExternal = true }; + writer.Write(method); + var result = tw.ToString(); + Assert.Contains("SetContentFromParsable", result); + AssertExtensions.CurlyBracesAreClosed(result); + } + [Fact] public void WritesRequestExecutorBody() { setup(); diff --git a/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs index f72be175aa..cf043d8c89 100644 --- a/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs @@ -591,12 +591,6 @@ private void AddRequestBodyParameters(bool useComplexTypeForBody = false) }, Optional = true, }); - method.AddParameter(new CodeParameter - { - Name = "r", - Kind = CodeParameterKind.ResponseHandler, - Type = stringType, - }); } [Fact] public void WritesNullableVoidTypeForExecutor() @@ -1139,6 +1133,20 @@ public void DoesntWriteFactorySwitchOnEmptyMappings() AssertExtensions.CurlyBracesAreClosed(result); } [Fact] + public void WritesRequestGeneratorBodyForMultipart() + { + setup(); + method.Kind = CodeMethodKind.RequestGenerator; + method.HttpMethod = HttpMethod.Post; + AddRequestProperties(); + AddRequestBodyParameters(); + method.Parameters.First(static x => x.IsOfKind(CodeParameterKind.RequestBody)).Type = new CodeType { Name = "MultipartBody", IsExternal = true }; + writer.Write(method); + var result = tw.ToString(); + Assert.Contains("setContentFromParsable", result); + AssertExtensions.CurlyBracesAreClosed(result); + } + [Fact] public void WritesRequestExecutorBodyForCollections() { setup(); diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs index 6afa0e9c19..d0b62e1b80 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs @@ -135,12 +135,6 @@ private void AddRequestBodyParameters(bool useComplexTypeForBody = false) }, Optional = true, }); - method.AddParameter(new CodeParameter - { - Name = "r", - Kind = CodeParameterKind.ResponseHandler, - Type = stringType, - }); } [Fact] public void WritesRequestBuilder() @@ -244,6 +238,19 @@ public void DoesntCreateDictionaryOnEmptyErrorMapping() AssertExtensions.CurlyBracesAreClosed(result); } [Fact] + public void WritesRequestGeneratorBodyForMultipart() + { + method.Kind = CodeMethodKind.RequestGenerator; + method.HttpMethod = HttpMethod.Post; + AddRequestProperties(); + AddRequestBodyParameters(); + method.Parameters.First(static x => x.IsOfKind(CodeParameterKind.RequestBody)).Type = new CodeType { Name = "MultipartBody", IsExternal = true }; + writer.Write(method); + var result = tw.ToString(); + Assert.Contains("setContentFromParsable", result); + AssertExtensions.CurlyBracesAreClosed(result); + } + [Fact] public void WritesRequestExecutorBodyForCollections() { method.Kind = CodeMethodKind.RequestExecutor;