diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5303727326..ef2cc5f75b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,89 +1,99 @@ version: 2 updates: -- package-ecosystem: nuget - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - labels: - - generator - groups: - kiota-dependencies: - patterns: - - "*kiota*" -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 + - package-ecosystem: nuget + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + labels: + - generator + groups: + kiota-dependencies: + patterns: + - "*kiota*" + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 -- package-ecosystem: nuget - directory: "/it/csharp" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - kiota-dependencies: - patterns: - - "*kiota*" + - package-ecosystem: nuget + directory: "/it/csharp" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" -- package-ecosystem: gomod - directory: "/it/go" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - kiota-dependencies: - patterns: - - "*kiota*" + - package-ecosystem: gomod + directory: "/it/go" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" -- package-ecosystem: composer - directory: "/it/php" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - kiota-dependencies: - patterns: - - "*kiota*" + - package-ecosystem: composer + directory: "/it/php" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" -- package-ecosystem: pip - directory: "/it/python" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - kiota-dependencies: - patterns: - - "*kiota*" + - package-ecosystem: pip + directory: "/it/python" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" -- package-ecosystem: bundler - directory: "/it/ruby" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - kiota-dependencies: - patterns: - - "*kiota*" + - package-ecosystem: bundler + directory: "/it/ruby" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" -- package-ecosystem: npm - directory: "/it/typescript" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - kiota-dependencies: - patterns: - - "*kiota*" + - package-ecosystem: maven + directory: "/it/java" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" -- package-ecosystem: npm - directory: "/vscode/microsoft-kiota" - schedule: - interval: daily - open-pull-requests-limit: 10 - groups: - eslint: - patterns: - - "*eslint*" + - package-ecosystem: npm + directory: "/it/typescript" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + kiota-dependencies: + patterns: + - "*kiota*" + + - package-ecosystem: npm + directory: "/vscode/microsoft-kiota" + schedule: + interval: daily + open-pull-requests-limit: 10 + groups: + eslint: + patterns: + - "*eslint*" diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 0d367a37e3..8e1fc56376 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -58,6 +58,8 @@ jobs: - "apisguru::twilio.com:api" - "apisguru::docusign.net" - "apisguru::github.com:api.github.com" + - "apisguru::apis.guru" + steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 47407350b6..784c561868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added a warning message in the CLI when using preview languages. [#4316](https://github.com/microsoft/kiota/issues/4316) +- Added support for handling untyped Json content in C#,Golang, TypeScript and Java. [#2319](https://github.com/microsoft/kiota/issues/2319) ### Changed @@ -646,9 +647,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a bug where path parameters would be missing if no operation was present at the segment the parameter is defined. [#1940](https://github.com/microsoft/kiota/issues/1940) - Fixed a bug where nested classes with long names caused compilation errors for java generated libraries. [#1949](https://github.com/microsoft/kiota/issues/1949) - Removed use of anonymous classes in java generated libraries to reduce the number of java classes created at compilation time. [#1980](https://github.com/microsoft/kiota/pull/1980) -- Fixed a bug where generation would result in wrong indentation in some classes for Python [#1996]((https://github.com/microsoft/kiota/issues/1996). -- Fixed a bug where error class modules were hardcoded for Python [#1999]((https://github.com/microsoft/kiota/issues/1999) -- Fixed a bug where generation would sometimes result in wrong original names for query parameters in Python [#2000]((https://github.com/microsoft/kiota/issues/2000). +- Fixed a bug where generation would result in wrong indentation in some classes for Python [#1996](https://github.com/microsoft/kiota/issues/1996). +- Fixed a bug where error class modules were hardcoded for Python [#1999](https://github.com/microsoft/kiota/issues/1999) +- Fixed a bug where generation would sometimes result in wrong original names for query parameters in Python [#2000](https://github.com/microsoft/kiota/issues/2000). - Fixed a bug where Java would fail to compile for endpoints that return collections. ## [0.7.1] - 2022-11-01 @@ -1287,8 +1288,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial GitHub release - - - - - diff --git a/it/config.json b/it/config.json index 6ef1c46a70..bef7691eac 100644 --- a/it/config.json +++ b/it/config.json @@ -339,5 +339,11 @@ "Rationale": "https://github.com/microsoft/kiota/issues/1812" } ] + }, + "apisguru::apis.guru": { + "Suppressions": [ + ], + "IdempotencySuppressions": [ + ] } } diff --git a/it/go/client/api_client.go b/it/go/client/api_client.go new file mode 100644 index 0000000000..6c66b46ae6 --- /dev/null +++ b/it/go/client/api_client.go @@ -0,0 +1,49 @@ +// This is a temporary file to be used until the code is generated and will be overwritten. +package client + +import ( + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" + i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" + i4bcdc892e61ac17e2afc10b5e2b536b29f4fd6c1ad30f4a5a68df47495db3347 "github.com/microsoft/kiota-serialization-form-go" + i25911dc319edd61cbac496af7eab5ef20b6069a42515e22ec6a9bc97bf598488 "github.com/microsoft/kiota-serialization-json-go" + i56887720f41ac882814261620b1c8459c4a992a0207af547c4453dd39fabc426 "github.com/microsoft/kiota-serialization-multipart-go" + i7294a22093d408fdca300f11b81a887d89c47b764af06c8b803e2323973fdb83 "github.com/microsoft/kiota-serialization-text-go" +) + +// ApiClient the main entry point of the SDK, exposes the configuration and the fluent API. +type ApiClient struct { + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder +} + +// NewApiClient instantiates a new ApiClient and sets the default values. +func NewApiClient(requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter) *ApiClient { + m := &ApiClient{ + BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}", map[string]string{}), + } + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultSerializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriterFactory { + return i25911dc319edd61cbac496af7eab5ef20b6069a42515e22ec6a9bc97bf598488.NewJsonSerializationWriterFactory() + }) + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultSerializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriterFactory { + return i7294a22093d408fdca300f11b81a887d89c47b764af06c8b803e2323973fdb83.NewTextSerializationWriterFactory() + }) + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultSerializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriterFactory { + return i4bcdc892e61ac17e2afc10b5e2b536b29f4fd6c1ad30f4a5a68df47495db3347.NewFormSerializationWriterFactory() + }) + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultSerializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriterFactory { + return i56887720f41ac882814261620b1c8459c4a992a0207af547c4453dd39fabc426.NewMultipartSerializationWriterFactory() + }) + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultDeserializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNodeFactory { + return i25911dc319edd61cbac496af7eab5ef20b6069a42515e22ec6a9bc97bf598488.NewJsonParseNodeFactory() + }) + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultDeserializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNodeFactory { + return i7294a22093d408fdca300f11b81a887d89c47b764af06c8b803e2323973fdb83.NewTextParseNodeFactory() + }) + i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RegisterDefaultDeserializer(func() i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNodeFactory { + return i4bcdc892e61ac17e2afc10b5e2b536b29f4fd6c1ad30f4a5a68df47495db3347.NewFormParseNodeFactory() + }) + if m.BaseRequestBuilder.RequestAdapter.GetBaseUrl() == "" { + m.BaseRequestBuilder.RequestAdapter.SetBaseUrl("https://localhost/v2") + } + m.BaseRequestBuilder.PathParameters["baseurl"] = m.BaseRequestBuilder.RequestAdapter.GetBaseUrl() + return m +} diff --git a/it/go/go.mod b/it/go/go.mod index f85968410d..c376a2fa48 100644 --- a/it/go/go.mod +++ b/it/go/go.mod @@ -3,37 +3,37 @@ module integrationtest go 1.20 require ( - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 - github.com/microsoft/kiota-abstractions-go v1.5.0 - github.com/microsoft/kiota-authentication-azure-go v1.0.1 - github.com/microsoft/kiota-http-go v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 + github.com/microsoft/kiota-abstractions-go v1.6.0 + github.com/microsoft/kiota-authentication-azure-go v1.0.2 + github.com/microsoft/kiota-http-go v1.3.3 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-json-go v1.0.7 github.com/microsoft/kiota-serialization-multipart-go v1.0.0 github.com/microsoft/kiota-serialization-text-go v1.0.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // 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.3.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.1.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/std-uritemplate/std-uritemplate/go v0.0.46 // indirect - github.com/stretchr/testify v1.8.4 // indirect - go.opentelemetry.io/otel v1.20.0 // indirect - go.opentelemetry.io/otel/metric v1.20.0 // indirect - go.opentelemetry.io/otel/trace v1.20.0 // indirect - golang.org/x/crypto v0.15.0 // indirect - golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.14.0 // indirect + github.com/std-uritemplate/std-uritemplate/go v0.0.55 // indirect + github.com/stretchr/testify v1.9.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/it/go/go.sum b/it/go/go.sum index be4954b5c8..2943be1ea8 100644 --- a/it/go/go.sum +++ b/it/go/go.sum @@ -1,65 +1,65 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= -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.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= -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/Azure/azure-sdk-for-go/sdk/azcore v1.10.0 h1:n1DH8TPV4qqPTje2RcUBYwtrTWlabVp4n46+74X2pn4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0/go.mod h1:HDcZnuGbiyppErN6lB+idp4CKhjbc8gwjto6OPpyggM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 h1:sO0/P7g68FrryJzljemN+6GTssUXdANk6aJ7T1ZxnsQ= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/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.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.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 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/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HWQU= -github.com/golang-jwt/jwt/v5 v5.1.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.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/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.5.0 h1:CD36eKsJ6NZLLu6LS5UqDPApIkrZEq2L7E0Uw/CTKzc= -github.com/microsoft/kiota-abstractions-go v1.5.0/go.mod h1:NRJnAFg8qqOoX/VQWTe3ZYmcIbLa20LNC+eTqO2j60U= -github.com/microsoft/kiota-authentication-azure-go v1.0.1 h1:F4HH+2QQHSecQg50gVEZaUcxA8/XxCaC2oOMYv2gTIM= -github.com/microsoft/kiota-authentication-azure-go v1.0.1/go.mod h1:IbifJeoi+sULI0vjnsWYSmDu5atFo/4FZ6WCoAkPjsc= -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-abstractions-go v1.6.0 h1:qbGBNMU0/o5myKbikCBXJFohVCFrrpx2cO15Rta2WyA= +github.com/microsoft/kiota-abstractions-go v1.6.0/go.mod h1:7YH20ZbRWXGfHSSvdHkdztzgCB9mRdtFx13+hrYIEpo= +github.com/microsoft/kiota-authentication-azure-go v1.0.2 h1:tClGeyFZJ+4Bakf8u0euPM4wqy4ethycdOgx3jyH3pI= +github.com/microsoft/kiota-authentication-azure-go v1.0.2/go.mod h1:aTcti0bUJEcq7kBfQG4Sr4ElvRNuaalXcFEu4iEyQ6M= +github.com/microsoft/kiota-http-go v1.3.3 h1:FKjK5BLFONu5eIBxtrkirkixFQmcPwitZ8iwZHKbESo= +github.com/microsoft/kiota-http-go v1.3.3/go.mod h1:IWw/PwtBs/GYz+Pa75gPW7MFNFv0aKPFsLw5WqzL1SE= 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= -github.com/microsoft/kiota-serialization-json-go v1.0.4/go.mod h1:rM4+FsAY+9AEpBsBzkFFis+b/LZLlNKKewuLwK9Q6Mg= +github.com/microsoft/kiota-serialization-json-go v1.0.7 h1:yMbckSTPrjZdM4EMXgzLZSA3CtDaUBI350u0VoYRz7Y= +github.com/microsoft/kiota-serialization-json-go v1.0.7/go.mod h1:1krrY7DYl3ivPIzl4xTaBpew6akYNa8/Tal8g+kb0cc= 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/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= 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/std-uritemplate/std-uritemplate/go v0.0.46 h1:rWcEym/hz9YhPTXJELTXfrq48lTx69jNVhv+dOMmyZY= -github.com/std-uritemplate/std-uritemplate/go v0.0.46/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= -go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc= -go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs= -go.opentelemetry.io/otel/metric v1.20.0 h1:ZlrO8Hu9+GAhnepmRGhSU7/VkpjrNowxRN9GyKR4wzA= -go.opentelemetry.io/otel/metric v1.20.0/go.mod h1:90DRw3nfK4D7Sm/75yQ00gTJxtkBxX+wu6YaNymbpVM= -go.opentelemetry.io/otel/trace v1.20.0 h1:+yxVAPZPbQhbC3OfAkeIVTky6iTFpcr4SiY9om7mXSQ= -go.opentelemetry.io/otel/trace v1.20.0/go.mod h1:HJSK7F/hA5RlzpZ0zKDCHCDHm556LCDtKaAo6JmBFUU= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +github.com/std-uritemplate/std-uritemplate/go v0.0.55 h1:muSH037g97K7U2f94G9LUuE8tZlJsoSSrPsO9V281WY= +github.com/std-uritemplate/std-uritemplate/go v0.0.55/go.mod h1:rG/bqh/ThY4xE5de7Rap3vaDkYUT76B0GPJ0loYeTTc= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/it/java/basic/pom.xml b/it/java/basic/pom.xml index 88757938f6..6f1bad14e6 100644 --- a/it/java/basic/pom.xml +++ b/it/java/basic/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.12.1 + 1.1.1 diff --git a/it/java/gh/pom.xml b/it/java/gh/pom.xml index 641d5bdc48..4dae43e904 100644 --- a/it/java/gh/pom.xml +++ b/it/java/gh/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.12.1 + 1.1.1 diff --git a/it/java/pom.xml b/it/java/pom.xml index f7135ceb7e..990679bc97 100644 --- a/it/java/pom.xml +++ b/it/java/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.12.1 + 1.1.1 diff --git a/it/java/query-params/pom.xml b/it/java/query-params/pom.xml index 88757938f6..6f1bad14e6 100644 --- a/it/java/query-params/pom.xml +++ b/it/java/query-params/pom.xml @@ -15,7 +15,7 @@ UTF-8 UTF-8 - 0.12.1 + 1.1.1 diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index b9ae9bf50d..c31550fdd8 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -505,6 +505,7 @@ public async Task CreateLanguageSourceFilesAsync(GenerationLanguage language, Co private const string CoreInterfaceType = "IRequestAdapter"; private const string RequestAdapterParameterName = "requestAdapter"; private const string ConstructorMethodName = "constructor"; + internal const string UntypedNodeName = "UntypedNode"; /// /// Create a CodeClass instance that is a request builder class for the OpenApiUrlTreeNode /// @@ -1038,7 +1039,7 @@ openApiExtension is OpenApiPrimaryErrorMessageExtension primaryErrorMessageExten if (typeSchema?.OneOf?.Any() ?? false) typeNames.AddRange(typeSchema.OneOf.Select(x => x.Type)); // double is sometimes an oneof string, number and enum // first value that's not null, and not "object" for primitive collections, the items type matters - var typeName = typeNames.FirstOrDefault(static x => !string.IsNullOrEmpty(x) && !typeNamesToSkip.Contains(x)); + var typeName = typeNames.Find(static x => !string.IsNullOrEmpty(x) && !typeNamesToSkip.Contains(x)); var isExternal = false; if (typeSchema?.Items?.IsEnum() ?? false) @@ -1617,7 +1618,7 @@ private CodeTypeBase CreateComposedModelDeclaration(OpenApiUrlTreeNode currentNo } return unionType; } - private CodeTypeBase? CreateModelDeclarations(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, CodeElement parentElement, string suffixForInlineSchema, OpenApiResponse? response = default, string typeNameForInlineSchema = "", bool isRequestBody = false) + private CodeTypeBase CreateModelDeclarations(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, CodeElement parentElement, string suffixForInlineSchema, OpenApiResponse? response = default, string typeNameForInlineSchema = "", bool isRequestBody = false) { var (codeNamespace, responseValue, suffix) = schema.IsReferencedSchema() switch { @@ -1662,13 +1663,13 @@ private CodeTypeBase CreateComposedModelDeclaration(OpenApiUrlTreeNode currentNo } if (!string.IsNullOrEmpty(schema.Type) || !string.IsNullOrEmpty(schema.Format)) - return GetPrimitiveType(schema, string.Empty); + return GetPrimitiveType(schema, string.Empty) ?? new CodeType { Name = UntypedNodeName, IsExternal = true }; if ((schema.AnyOf.Any() || schema.OneOf.Any() || schema.AllOf.Any()) && (schema.AnyOf.FirstOrDefault(static x => x.IsSemanticallyMeaningful(true)) ?? schema.OneOf.FirstOrDefault(static x => x.IsSemanticallyMeaningful(true)) ?? schema.AllOf.FirstOrDefault(static x => x.IsSemanticallyMeaningful(true))) is { } childSchema) // we have an empty node because of some local override for schema properties and need to unwrap it. return CreateModelDeclarations(currentNode, childSchema, operation, parentElement, suffixForInlineSchema, response, typeNameForInlineSchema, isRequestBody); - return null; + return new CodeType { Name = UntypedNodeName, IsExternal = true }; } - private CodeTypeBase? CreateCollectionModelDeclaration(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, CodeNamespace codeNamespace, string typeNameForInlineSchema, bool isRequestBody) + private CodeTypeBase CreateCollectionModelDeclaration(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, CodeNamespace codeNamespace, string typeNameForInlineSchema, bool isRequestBody) { CodeTypeBase? type = GetPrimitiveType(schema.Items, string.Empty); var isEnumOrComposedCollectionType = schema.Items.IsEnum() //the collection could be an enum type so override with strong type instead of string type. @@ -1680,7 +1681,8 @@ private CodeTypeBase CreateComposedModelDeclaration(OpenApiUrlTreeNode currentNo var targetNamespace = GetShortestNamespace(codeNamespace, schema.Items); type = CreateModelDeclarations(currentNode, schema.Items, operation, targetNamespace, string.Empty, typeNameForInlineSchema: typeNameForInlineSchema, isRequestBody: isRequestBody); } - if (type is null) return null; + if (type is null) + return new CodeType { Name = UntypedNodeName, IsExternal = true }; type.CollectionKind = CodeTypeBase.CodeTypeCollectionKind.Complex; return type; } diff --git a/src/Kiota.Builder/Refiners/CSharpRefiner.cs b/src/Kiota.Builder/Refiners/CSharpRefiner.cs index 9ca8c9241e..f618db0898 100644 --- a/src/Kiota.Builder/Refiners/CSharpRefiner.cs +++ b/src/Kiota.Builder/Refiners/CSharpRefiner.cs @@ -183,6 +183,8 @@ protected static void MakeEnumPropertiesNullable(CodeElement currentElement) SerializationNamespaceName, "ParseNodeHelper"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Headers), AbstractionsNamespaceName, "RequestHeaders"), + new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Custom) && prop.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase), + SerializationNamespaceName, KiotaBuilder.UntypedNodeName), new (static x => x is CodeEnum prop && prop.Options.Any(x => x.IsNameEscaped), "System.Runtime.Serialization", "EnumMemberAttribute"), new (static x => x is IDeprecableElement element && element.Deprecation is not null && element.Deprecation.IsDeprecated, diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs index 30b1b21455..b4073dc385 100644 --- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs +++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs @@ -1444,6 +1444,16 @@ protected static void RemoveRequestConfigurationClassesCommonProperties(CodeElem CrawlTree(currentElement, x => RemoveRequestConfigurationClassesCommonProperties(x, baseTypeUsing)); } + protected static void RemoveUntypedNodePropertyValues(CodeElement currentElement) + { + if (currentElement is CodeProperty currentProperty + && currentElement.Parent is CodeClass parentClass + && currentProperty.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)) + { + parentClass.RemoveChildElement(currentProperty); + } + CrawlTree(currentElement, RemoveUntypedNodePropertyValues); + } protected static void RemoveRequestConfigurationClasses(CodeElement currentElement, CodeUsing? configurationParameterTypeUsing = null, CodeType? defaultValueForGenericTypeParam = null, bool keepRequestConfigurationClass = false, bool addDeprecation = false, CodeUsing? usingForDefaultGenericParameter = null) { if (currentElement is CodeClass currentClass && currentClass.IsOfKind(CodeClassKind.RequestConfiguration) && @@ -1490,6 +1500,7 @@ private static CodeType GetGenericTypeForRequestConfiguration(CodeType configura newType.GenericTypeParameterValues.Add(genericTypeParamValue); return newType; } + internal static void AddPrimaryErrorMessage(CodeElement currentElement, string name, Func type, bool asProperty = false) { if (currentElement is CodeClass { IsErrorDefinition: true } currentClass) diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index fcdd9bce1d..7dafcd70f0 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -570,7 +570,7 @@ private static void AddErrorAndStringsImportForEnums(CodeElement currentElement) new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer, CodeMethodKind.Factory), "github.com/microsoft/kiota-abstractions-go/serialization", "ParseNode", "Parsable"), new (static x => x is CodeClass codeClass && codeClass.IsOfKind(CodeClassKind.Model), - "github.com/microsoft/kiota-abstractions-go/serialization", "Parsable"), + SerializationNamespaceName, "Parsable"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator) && method.Parameters.Any(x => x.IsOfKind(CodeParameterKind.RequestBody) && @@ -578,16 +578,16 @@ private static void AddErrorAndStringsImportForEnums(CodeElement currentElement) x.Type is CodeType pType && (pType.TypeDefinition is CodeClass || pType.TypeDefinition is CodeInterface)), - "github.com/microsoft/kiota-abstractions-go/serialization", "Parsable"), + SerializationNamespaceName, "Parsable"), new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model) && (@class.Properties.Any(x => x.IsOfKind(CodePropertyKind.AdditionalData)) || @class.StartBlock.Implements.Any(x => KiotaBuilder.AdditionalHolderInterface.Equals(x.Name, StringComparison.OrdinalIgnoreCase))), - "github.com/microsoft/kiota-abstractions-go/serialization", "AdditionalDataHolder"), + SerializationNamespaceName, "AdditionalDataHolder"), new (static x => x is CodeClass @class && @class.OriginalComposedType is CodeUnionType unionType && unionType.Types.Any(static y => !y.IsExternal) && unionType.DiscriminatorInformation.HasBasicDiscriminatorInformation, "strings", "EqualFold"), new (static x => x is CodeMethod method && (method.IsOfKind(CodeMethodKind.RequestExecutor) || method.IsOfKind(CodeMethodKind.RequestGenerator)), "context","*context"), 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"), + SerializationNamespaceName, "MergeDeserializersForIntersectionWrapper"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Headers), AbstractionsNamespaceName, "RequestHeaders"), new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.BackingStore), "github.com/microsoft/kiota-abstractions-go/store","BackingStore"), @@ -596,10 +596,14 @@ x.Type is CodeType pType && "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), + new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Custom) && prop.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase), + SerializationNamespaceName, KiotaBuilder.UntypedNodeName), new (static x => x is CodeEnum @enum && @enum.Flags,"", "math"), }; private const string MultipartBodyClassName = "MultipartBody"; private const string AbstractionsNamespaceName = "github.com/microsoft/kiota-abstractions-go"; + private const string SerializationNamespaceName = "github.com/microsoft/kiota-abstractions-go/serialization"; + internal const string UntypedNodeName = "UntypedNodeable"; private void CorrectImplements(ProprietableBlockDeclaration block) { @@ -672,21 +676,21 @@ private static void CorrectMethodType(CodeMethod currentMethod) {"TimeSpan", ("ISODuration", new CodeUsing { Name = "ISODuration", Declaration = new CodeType { - Name = "github.com/microsoft/kiota-abstractions-go/serialization", + Name = SerializationNamespaceName, IsExternal = true, }, })}, {"DateOnly", (string.Empty, new CodeUsing { Name = "DateOnly", Declaration = new CodeType { - Name = "github.com/microsoft/kiota-abstractions-go/serialization", + Name = SerializationNamespaceName, IsExternal = true, }, })}, {"TimeOnly", (string.Empty, new CodeUsing { Name = "TimeOnly", Declaration = new CodeType { - Name = "github.com/microsoft/kiota-abstractions-go/serialization", + Name = SerializationNamespaceName, IsExternal = true, }, })}, @@ -697,6 +701,13 @@ private static void CorrectMethodType(CodeMethod currentMethod) IsExternal = true, }, })}, + {KiotaBuilder.UntypedNodeName, (GoRefiner.UntypedNodeName, new CodeUsing { + Name = GoRefiner.UntypedNodeName, + Declaration = new CodeType { + Name = SerializationNamespaceName, + IsExternal = true, + }, + })}, }; private static void CorrectPropertyType(CodeProperty currentProperty) { diff --git a/src/Kiota.Builder/Refiners/JavaRefiner.cs b/src/Kiota.Builder/Refiners/JavaRefiner.cs index d1237449bf..1890dd04c7 100644 --- a/src/Kiota.Builder/Refiners/JavaRefiner.cs +++ b/src/Kiota.Builder/Refiners/JavaRefiner.cs @@ -264,6 +264,8 @@ private static void AddEnumSetImport(CodeElement currentElement) AbstractionsNamespaceName, "QueryParameters"), 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 CodeProperty prop && prop.IsOfKind(CodePropertyKind.Custom) && prop.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase), + SerializationNamespaceName, KiotaBuilder.UntypedNodeName), 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) }; diff --git a/src/Kiota.Builder/Refiners/PhpRefiner.cs b/src/Kiota.Builder/Refiners/PhpRefiner.cs index e53a544de7..1a9e65896e 100644 --- a/src/Kiota.Builder/Refiners/PhpRefiner.cs +++ b/src/Kiota.Builder/Refiners/PhpRefiner.cs @@ -53,6 +53,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance AddParsableImplementsForModelClasses(generatedCode, "Parsable"); AddRequestConfigurationConstructors(generatedCode); AddDefaultImports(generatedCode, defaultUsingEvaluators); + RemoveUntypedNodePropertyValues(generatedCode); AddCollectionValidationUtilImportToModels(generatedCode); cancellationToken.ThrowIfCancellationRequested(); AddGetterAndSetterMethods(generatedCode, diff --git a/src/Kiota.Builder/Refiners/PythonRefiner.cs b/src/Kiota.Builder/Refiners/PythonRefiner.cs index 3b0bf0adb4..5c8278dc35 100644 --- a/src/Kiota.Builder/Refiners/PythonRefiner.cs +++ b/src/Kiota.Builder/Refiners/PythonRefiner.cs @@ -26,6 +26,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance ); CorrectCommonNames(generatedCode); RemoveMethodByKind(generatedCode, CodeMethodKind.RawUrlConstructor); + RemoveUntypedNodePropertyValues(generatedCode); DisableActionOf(generatedCode, CodeParameterKind.RequestConfiguration); MoveRequestBuilderPropertiesToBaseType(generatedCode, diff --git a/src/Kiota.Builder/Refiners/RubyRefiner.cs b/src/Kiota.Builder/Refiners/RubyRefiner.cs index 0c334b3579..35fce88137 100644 --- a/src/Kiota.Builder/Refiners/RubyRefiner.cs +++ b/src/Kiota.Builder/Refiners/RubyRefiner.cs @@ -63,6 +63,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance cancellationToken.ThrowIfCancellationRequested(); AddParsableImplementsForModelClasses(generatedCode, "MicrosoftKiotaAbstractions::Parsable"); AddDefaultImports(generatedCode, defaultUsingEvaluators); + RemoveUntypedNodePropertyValues(generatedCode); CorrectCoreType(generatedCode, CorrectMethodType, CorrectPropertyType, CorrectImplements); cancellationToken.ThrowIfCancellationRequested(); ReplacePropertyNames(generatedCode, diff --git a/src/Kiota.Builder/Refiners/SwiftRefiner.cs b/src/Kiota.Builder/Refiners/SwiftRefiner.cs index 0d1d59ca6f..0322819079 100644 --- a/src/Kiota.Builder/Refiners/SwiftRefiner.cs +++ b/src/Kiota.Builder/Refiners/SwiftRefiner.cs @@ -44,6 +44,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance AddDefaultImports( generatedCode, defaultUsingEvaluators); + RemoveUntypedNodePropertyValues(generatedCode); cancellationToken.ThrowIfCancellationRequested(); CorrectCoreType( generatedCode, diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index 65a217ec15..7a3d3aa436 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -527,7 +527,9 @@ private static bool HasMultipartBody(CodeMethod m) => new (static x => x is CodeProperty prop && prop.Kind is CodePropertyKind.BackingStore, AbstractionsPackageName, true, "BackingStore", "BackedModel"), new (static x => x is CodeMethod m && HasMultipartBody(m), - AbstractionsPackageName, MultipartBodyClassName, $"serialize{MultipartBodyClassName}") + AbstractionsPackageName, MultipartBodyClassName, $"serialize{MultipartBodyClassName}"), + new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Custom) && prop.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase), + AbstractionsPackageName, KiotaBuilder.UntypedNodeName, "createUntypedNodeFromDiscriminatorValue"), }; private const string MultipartBodyClassName = "MultipartBody"; private static void CorrectImplements(ProprietableBlockDeclaration block) diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs index 41b1456864..989c9df1d7 100644 --- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs @@ -4,6 +4,7 @@ using Kiota.Builder.CodeDOM; using Kiota.Builder.Extensions; +using Kiota.Builder.Refiners; namespace Kiota.Builder.Writers.Go; public class CodeMethodWriter : BaseElementWriter @@ -708,6 +709,7 @@ private void WriteFieldDeserializer(CodeProperty property, LanguageWriter writer (CodeInterface, false) => (GetTypeAssertion("val", propertyTypeImportName), string.Empty, false), (CodeInterface, true) => ("res", string.Empty, false), (_, true) => ("res", "*", true), + (null, false) when property.Type.AllTypes.First().Name.Equals(GoRefiner.UntypedNodeName, StringComparison.OrdinalIgnoreCase) => (GetTypeAssertion("val", $"{propertyTypeImportName}"), string.Empty, true), _ => ("val", string.Empty, true), }; if (property.Type.CollectionKind != CodeTypeBase.CodeTypeCollectionKind.None) @@ -978,7 +980,7 @@ private void WriteSerializationMethodCall(CodeTypeBase propType, CodeElement par serializationKey = $"\"{serializationKey}\""; var errorPrefix = $"err {errorVarDeclaration(shouldDeclareErrorVar)}= writer."; var isEnum = propType is CodeType eType && eType.TypeDefinition is CodeEnum; - var isComplexType = propType is CodeType cType && (cType.TypeDefinition is CodeClass || cType.TypeDefinition is CodeInterface); + var isComplexType = propType is CodeType cType && (cType.TypeDefinition is CodeClass || cType.TypeDefinition is CodeInterface || cType.Name.Equals(GoRefiner.UntypedNodeName, StringComparison.OrdinalIgnoreCase)); var isInterface = propType is CodeType iType && iType.TypeDefinition is CodeInterface; if (addBlockForErrorScope) if (isEnum || propType.IsCollection) diff --git a/src/Kiota.Builder/Writers/Go/GoConventionService.cs b/src/Kiota.Builder/Writers/Go/GoConventionService.cs index df513ad5be..5582ba25b8 100644 --- a/src/Kiota.Builder/Writers/Go/GoConventionService.cs +++ b/src/Kiota.Builder/Writers/Go/GoConventionService.cs @@ -5,6 +5,7 @@ using Kiota.Builder.CodeDOM; using Kiota.Builder.Extensions; +using Kiota.Builder.Refiners; namespace Kiota.Builder.Writers.Go; public class GoConventionService : CommonLanguageConventionService @@ -62,6 +63,7 @@ public string GetTypeString(CodeTypeBase code, CodeElement targetElement, bool i currentType.IsNullable && currentType.TypeDefinition is not CodeInterface && currentType.CollectionKind == CodeTypeBase.CodeTypeCollectionKind.None && + !currentType.Name.Equals(GoRefiner.UntypedNodeName, StringComparison.OrdinalIgnoreCase) && !IsScalarType(currentType.Name) ? "*" : string.Empty; var collectionPrefix = currentType.CollectionKind switch diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 69d1eb4ca7..3cf5b8bbd0 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -1357,8 +1357,8 @@ public void Object_Arrays_are_supported() var valueProp = userResponseClass.FindChildByName("value", false); Assert.NotNull(valueProp); var unknownProp = userResponseClass.FindChildByName("unknown", false); - Assert.Null(unknownProp); - Assert.Equal(1, mockLogger.Count.First(static x => x.Key == LogLevel.Warning).Value); + Assert.NotNull(unknownProp); + Assert.Equal(KiotaBuilder.UntypedNodeName, unknownProp.Type.Name);// left out property is an UntypedNode } [Fact] public void TextPlainEndpointsAreSupported() @@ -6810,7 +6810,10 @@ public async Task SkipsInvalidItemsProperties() var resultClass = codeModel.FindChildByName("DirectoryObjectGetResponse"); Assert.NotNull(resultClass); var keysToCheck = new HashSet(StringComparer.OrdinalIgnoreCase) { "datasets", "datakeys", "datainfo" }; - Assert.Empty(resultClass.Properties.Where(x => x.IsOfKind(CodePropertyKind.Custom) && keysToCheck.Contains(x.Name))); + var propertiesToValidate = resultClass.Properties.Where(x => x.IsOfKind(CodePropertyKind.Custom) && keysToCheck.Contains(x.Name)).ToArray(); + Assert.NotNull(propertiesToValidate); + Assert.NotEmpty(propertiesToValidate); + Assert.Equal(keysToCheck.Count, propertiesToValidate.Length);// all the properties are present Assert.Single(resultClass.Properties.Where(x => x.IsOfKind(CodePropertyKind.Custom) && x.Name.Equals("id", StringComparison.OrdinalIgnoreCase))); } [Fact] diff --git a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs index 85e263c2f3..27b5091fd4 100644 --- a/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/CSharpLanguageRefinerTests.cs @@ -662,5 +662,30 @@ public async Task ReplacesLocallyDefinedTimeOnlyByNativeType() Assert.NotEmpty(model.StartBlock.Usings); Assert.Equal("TimeOnlyObject", method.ReturnType.Name); } + [Fact] + public async Task AddsUsingForUntypedNode() + { + var model = root.AddClass(new CodeClass + { + Name = "model", + Kind = CodeClassKind.Model + }).First(); + var property = model.AddProperty(new CodeProperty + { + Name = "property", + Type = new CodeType + { + Name = KiotaBuilder.UntypedNodeName, + IsExternal = true + }, + }).First(); + await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.CSharp }, root); + Assert.Equal(KiotaBuilder.UntypedNodeName, property.Type.Name); + Assert.NotEmpty(model.StartBlock.Usings); + var nodeUsing = model.StartBlock.Usings.Where(static declaredUsing => declaredUsing.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)).ToArray(); + Assert.Single(nodeUsing); + Assert.Equal("Microsoft.Kiota.Abstractions.Serialization", nodeUsing[0].Declaration.Name); + + } #endregion } diff --git a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs index 3d7d08a7f0..9857df54d6 100644 --- a/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/GoLanguageRefinerTests.cs @@ -1074,5 +1074,29 @@ public async Task AddsMethodsOverloads() Assert.Contains(childMethods, x => !x.IsOverload && x.IsOfKind(CodeMethodKind.RequestGenerator) && x.Parameters.Count() == 3);// ctx + body + query config Assert.Equal(2, childMethods.Count()); } + [Fact] + public async Task AddsUsingForUntypedNode() + { + var model = root.AddClass(new CodeClass + { + Name = "model", + Kind = CodeClassKind.Model + }).First(); + var property = model.AddProperty(new CodeProperty + { + Name = "property", + Type = new CodeType + { + Name = KiotaBuilder.UntypedNodeName, + IsExternal = true + }, + }).First(); + await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Go }, root); + Assert.Equal(GoRefiner.UntypedNodeName, property.Type.Name);// type is renamed + Assert.NotEmpty(model.StartBlock.Usings); + var nodeUsing = model.StartBlock.Usings.Where(static declaredUsing => declaredUsing.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)).ToArray(); + Assert.Single(nodeUsing); + Assert.Equal("github.com/microsoft/kiota-abstractions-go/serialization", nodeUsing[0].Declaration.Name); + } #endregion } diff --git a/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs index b8416e1fc5..8c36e68216 100644 --- a/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/JavaLanguageRefinerTests.cs @@ -702,5 +702,30 @@ public async Task SplitsLongRefiners() Assert.Equal(4, model.Methods.Count()); Assert.Equal("String", model.Methods.First(static x => x.IsOverload).Parameters.First().Type.Name); } + + [Fact] + public async Task AddsUsingForUntypedNode() + { + var model = root.AddClass(new CodeClass + { + Name = "model", + Kind = CodeClassKind.Model + }).First(); + var property = model.AddProperty(new CodeProperty + { + Name = "property", + Type = new CodeType + { + Name = KiotaBuilder.UntypedNodeName, + IsExternal = true + }, + }).First(); + await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.Java }, root); + Assert.Equal(KiotaBuilder.UntypedNodeName, property.Type.Name); + Assert.NotEmpty(model.StartBlock.Usings); + var nodeUsing = model.StartBlock.Usings.Where(static declaredUsing => declaredUsing.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)).ToArray(); + Assert.Single(nodeUsing); + Assert.Equal("com.microsoft.kiota.serialization", nodeUsing[0].Declaration.Name); + } #endregion } diff --git a/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs index b3030025e0..e7704461fa 100644 --- a/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs +++ b/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs @@ -802,5 +802,26 @@ public async Task GeneratesCodeFiles() Assert.Null(root.FindChildByName($"{model.Name.ToFirstCharacterUpperCase()}", false)); } + [Fact] + public async Task AddsUsingForUntypedNode() + { + var generationConfiguration = new GenerationConfiguration { Language = GenerationLanguage.TypeScript }; + var model = TestHelper.CreateModelClassInModelsNamespace(generationConfiguration, root); + var property = model.AddProperty(new CodeProperty + { + Name = "property", + Type = new CodeType + { + Name = KiotaBuilder.UntypedNodeName, + IsExternal = true + }, + }).First(); + await ILanguageRefiner.Refine(new GenerationConfiguration { Language = GenerationLanguage.TypeScript }, root); + Assert.Equal(KiotaBuilder.UntypedNodeName, property.Type.Name);// type is renamed + Assert.NotEmpty(model.StartBlock.Usings); + var nodeUsing = model.StartBlock.Usings.Where(static declaredUsing => declaredUsing.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)).ToArray(); + Assert.Single(nodeUsing); + Assert.Equal("@microsoft/kiota-abstractions", nodeUsing[0].Declaration.Name); + } #endregion }