Merge branch 'main' into elinor/add-kiota-workspace

This commit is contained in:
Elinor 2024-08-15 12:47:03 +03:00 коммит произвёл GitHub
Родитель 8f5f368f18 27725ded34
Коммит b9881af907
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
18 изменённых файлов: 218 добавлений и 123 удалений

6
.github/workflows/docker.yml поставляемый
Просмотреть файл

@ -25,7 +25,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6.6.1
uses: docker/build-push-action@v6.7.0
with:
push: false
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
@ -94,7 +94,7 @@ jobs:
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Push to GitHub Packages - Nightly
if: contains(github.ref, env.PREVIEW_BRANCH)
uses: docker/build-push-action@v6.6.1
uses: docker/build-push-action@v6.7.0
with:
push: true
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
@ -104,7 +104,7 @@ jobs:
# we can't get the sequence number from ADO so we default it back to github run number
- name: Push to GitHub Packages - Release
if: contains(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v6.6.1
uses: docker/build-push-action@v6.7.0
with:
push: true
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7

2
.vscode/settings.json поставляемый
Просмотреть файл

@ -35,6 +35,7 @@
"ghes",
"inheritdoc",
"Kiota",
"microsoftgraph",
"NETCOREAPP",
"Nethttplibrary",
"NETSTANDARD",
@ -44,6 +45,7 @@
"pwsh",
"samespaceprefix",
"serializers",
"sonarcloud",
"Xunit"
],
"java.configuration.updateBuildConfiguration": "automatic",

Просмотреть файл

@ -13,7 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Reverts modification of responses in output openApi file when generating plugings [#4945](https://github.com/microsoft/kiota/issues/4945)
- Fixed an issue where models would be missing when they had no properties and a single allOf entry. [#5014](https://github.com/microsoft/kiota/issues/5014)
- Reverts modification of responses in output openApi file when generating plugins [#4945](https://github.com/microsoft/kiota/issues/4945)
- Expand properties types with null type for Typescript. [#4993](https://github.com/microsoft/kiota-typescript/issues/1188)
## [1.17.0] - 2024-08-09
@ -30,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug in Go where certain namespaces were escaped unexpectedly. [#5012](https://github.com/microsoft/kiota/issues/5012)
- Exclude the `x-openai-isConsequential` extension from cleanup. [#4962](https://github.com/microsoft/kiota/issues/4962)
- Fixed file name and namespace sanitization when generating plugins. [#5019](https://github.com/microsoft/kiota/issues/5019)
- Added TypeScript typecheck suppression to generated method prototype, where anused arguments can cause build fail in projects which use `noUnusedLocals: true` compiler option. [#5095](https://github.com/microsoft/kiota/issues/5095)
- Added TypeScript type check suppression to generated method prototype, where unused arguments can cause build fail in projects which use `noUnusedLocals: true` compiler option. [#5095](https://github.com/microsoft/kiota/issues/5095)
- Fixed a bug where defensive programming would consider some default values as invalid in Python.
## [1.16.0] - 2024-07-05
@ -101,8 +103,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixes a bug where warnings about discriminator not being inherited were generated [#4761](https://github.com/microsoft/kiota/issues/4761)
- Fix scalar member composed type serialization in PHP [#2827](https://github.com/microsoft/kiota/issues/2827)
- Trims unused components from output openApi document when generating plugins [#4672](https://github.com/microsoft/kiota/issues/4672)
- Fixes missing imports for UntypedNode when backingstore is enabled in Java.
- Renames `name_to_be_defined` plugin type to `apiplugin` [#4713](https://github.com/microsoft/kiota/issues/4713)
- Fixes missing imports for UntypedNode when BackingStore is enabled in Java.
- Renames `name_to_be_defined` plugin type to `APIplugin` [#4713](https://github.com/microsoft/kiota/issues/4713)
## [1.14.0] - 2024-05-02
@ -132,14 +134,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
- Added TypeScript typecheck suppression to `.ts` files where unused imports cause build fail in projects which use `noUnusedLocals: true` compiler option. [#4397](https://github.com/microsoft/kiota/issues/4397)
- Added TypeScript type check suppression to `.ts` files where unused imports cause build fail in projects which use `noUnusedLocals: true` compiler option. [#4397](https://github.com/microsoft/kiota/issues/4397)
- Fixed TypeScript generation bug when returning enums from endpoints. [#4426](https://github.com/microsoft/kiota/issues/4426)
### Changed
- Fixed Go generation bug when dealing with scalar collection body. [#4380](https://github.com/microsoft/kiota/issues/4380)
- Fixed a bug where multiple Visual Studio Code instances would make the extension install/update fail. [#3686](https://github.com/microsoft/kiota/issues/3686)
- Fixed a bug where models properties named "additionalData" or "backingstore" would be ignored. [#4224](https://github.com/microsoft/kiota/issues/4224)
- Fixed a bug where models properties named "additionalData" or "BackingStore" would be ignored. [#4224](https://github.com/microsoft/kiota/issues/4224)
- PREVIEW: Renamed the config commands to workspace. [#4310](https://github.com/microsoft/kiota/issues/4310)
- PREVIEW: Moved preview configuration files to the .kiota directory. [#4310](https://github.com/microsoft/kiota/issues/4310)
- PREVIEW: Moved the copy descriptions to dedicated folders. [#4310](https://github.com/microsoft/kiota/issues/4310)
@ -254,7 +256,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where path parameters deduplication would create collisions on sub path segments. [#3757](https://github.com/microsoft/kiota/issues/3757)
- Moved from net7 to net8.
- Removed windows OS from docker multi-platform image to align with [dotnet changes](https://github.com/dotnet/dotnet-docker/issues/4492).
- Fixed a bug where the emitted CSharp would not be compatible with netstandad2.0. [#3829](https://github.com/microsoft/kiota/issues/3829)
- Fixed a bug where the emitted CSharp would not be compatible with netstandard2.0. [#3829](https://github.com/microsoft/kiota/issues/3829)
- Fixed a bug where import statements for additionalDataHolder and enumSet are missing when BackingStore is enabled in java. [#3643](https://github.com/microsoft/kiota/pull/3643)
- Fixed an issue where Kiota's regex's might time out. [#3797](https://github.com/microsoft/kiota/issues/3797)
- Fixed a bug where getBackingStore method body was malformed for java. [#3643](https://github.com/microsoft/kiota/pull/3643)
@ -472,7 +474,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Changed python model classes to dataclasses. [#2684](https://github.com/microsoft/kiota/issues/2684)
- Changed python model classes to data classes. [#2684](https://github.com/microsoft/kiota/issues/2684)
- Fix issue with command conflicts causing CLI crashes. (Shell)
- Fix build error by splitting the ambiguous `--file` option into `--input-file` and `--output-file`. (Shell)
- Fixed including unused imports in Go [#2699](https://github.com/microsoft/kiota/pull/2410)
@ -656,7 +658,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated the client constructor to set the baseUrl path parameter from RequestAdapter's baseUrl(PHP) [#2129](https://github.com/microsoft/kiota/issues/2129)
- The Lock file uses a project version coming from a Source Generator instead of the one looked up with reflection. [#2147](https://github.com/microsoft/kiota/issues/2147)
- Fixed a bug in ruby where file names or paths could be too long to be packaged.
- Fixed a bug where models descriptions would be undeterministic. [#2130](https://github.com/microsoft/kiota/issues/2130)
- Fixed a bug where models descriptions would be non-deterministic. [#2130](https://github.com/microsoft/kiota/issues/2130)
- Fixed a bug in dotnet where default values for Enum properties with special characters would not match the model. [#2091](https://github.com/microsoft/kiota/issues/2091)
- Sets the base url to make use of request information easier in CSharp/Java/TypeScript/Go/Ruby. [#2061](https://github.com/microsoft/kiota/issues/2061)
- Renamed CreateXXXRequestInformation methods to ToXXXRequestInformation for a better auto-completion experience. [#2071](https://github.com/microsoft/kiota/issues/2071)
@ -760,7 +762,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for scalar request bodies in PHP [#1937](https://github.com/microsoft/kiota/pull/1937)
- Added accept header for all schematized requests Python. [#1617](https://github.com/microsoft/kiota/issues/1617)
- Added optional backing store support for PHP. [#1976](https://github.com/microsoft/kiota/pull/1976)
- Fixed a bug where OdataErrors had wrong inherited class name in Python.
- Fixed a bug where ODataErrors had wrong inherited class name in Python.
- Fixed a bug where empty path parameters dictionary would throw an error in request builders in Python.
### Changed
@ -793,7 +795,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for enum and collection of enum return types for Java.
- Added support for types with more than 500 discriminator entries in Java.
- Added a confirmation message once the generation is successful. [#1898](https://github.com/microsoft/kiota/issues/1898)
- Added colour scheme for all console messages to improve readability. [#1895](https://github.com/microsoft/kiota/issues/1895)
- Added color scheme for all console messages to improve readability. [#1895](https://github.com/microsoft/kiota/issues/1895)
### Changed
@ -807,7 +809,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where info and show commands would crash in case of invalid description URL. [#1894](https://github.com/microsoft/kiota/issues/1894)
- Show command now reads descriptions directly from APIs.guru instead of their origin. [#1897](https://github.com/microsoft/kiota/issues/1897)
- Fixed a classnames having the same name as extensions would cause generation to fail. [#1892](https://github.com/microsoft/kiota/issues/1892)
- Fixed an issue where CSharp defensive programing would use string.IsNullOrEmpty for collections parameters.
- Fixed an issue where CSharp defensive programming would use string.IsNullOrEmpty for collections parameters.
## [0.6.0] - 2022-10-06
@ -861,7 +863,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Fixed a bug where Go clients would panic in case of nil response value.
- Fixed a bug to properly add request headers to Nethttp requests in Ruby.
- Fixed a bug to properly add request headers to NetHttp requests in Ruby.
- Fixed a bug to properly reject invalid URLs in Ruby.
- Fixed an issue with require statements being generated instead of require relative in Ruby.
- Updated AdditionDataHolder with the correct namespace. (Ruby)
@ -887,7 +889,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where Java would skip duplicated imports instead of deduplicating them.
- Fixed a bug where Java would not convert date types for query parameters.
- Fixed a bug where Java doc comments could contain invalid characters.
- Fixed a bug where function parameters would be reodered incorrectly in dotnet[#1822](https://github.com/microsoft/kiota/issues/1822)
- Fixed a bug where function parameters would be reordered incorrectly in dotnet[#1822](https://github.com/microsoft/kiota/issues/1822)
## [0.4.0] - 2022-08-18
@ -907,11 +909,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where collections types would generate invalid return types in CSharp.
- Fixed a bug where a nullable entry in anyOf schemas would create unnecessary composed types.
- Removed duplicate properties defined in base types from model serialization and deserialization methods and initialise property defaults in constructor. [#1737](https://github.com/microsoft/kiota/pull/1737)
- Removed duplicate properties defined in base types from model serialization and deserialization methods and initialize property defaults in constructor. [#1737](https://github.com/microsoft/kiota/pull/1737)
- Fixed a bug where the generated code had incorrect casing within a method (Ruby). [#1672](https://github.com/microsoft/kiota/issues/1672)
- Fixed an issue where duplicate 'require' statements are generated for inner classes in the middle of the file (Ruby). [#1649](https://github.com/microsoft/kiota/issues/1649)
- Split parsable interface and additional property/data interface in Ruby. [#1654](https://github.com/microsoft/kiota/issues/1654)
- Changed format of datetimes in Go to be converted to ISO 8601 by default when place in path parameters(Go)
- Changed format of datetime in Go to be converted to ISO 8601 by default when place in path parameters(Go)
- Defined the Access Token Provider Interface for Ruby authentication. [#1638](https://github.com/microsoft/kiota/issues/1638)
- Reduce code verbosity on Go Getters and Setters. [G0#26](https://github.com/microsoftgraph/msgraph-sdk-go-core/issues/26)
@ -935,7 +937,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where query parameter types would not consider the format. [#1721](https://github.com/microsoft/kiota/issues/1721)
- Fixed a bug where discriminator mappings across namespaces could create circular dependencies in Go. [#1712](https://github.com/microsoft/kiota/issues/1712)
- Fixed a bug where Go binary downloads would try to parse a structured object.
- Aligned mime types model generation behaviour for request bodies on response content. [#134](https://github.com/microsoft/kiota/issues/134)
- Aligned mime types model generation behavior for request bodies on response content. [#134](https://github.com/microsoft/kiota/issues/134)
- Fixed an issue where some critical errors would not return a failed exit code. [#1605](https://github.com/microsoft/kiota/issues/1605)
- Moved nested request configuration classes into separate files within the namespace for PHP. [#1620](https://github.com/microsoft/kiota/pull/1620)
- Fixed an issue where duplicate 'require' statements are generated for inner classes in the middle of the file (Ruby). [#1649](https://github.com/microsoft/kiota/issues/1649)
@ -1136,9 +1138,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- BREAKING: Remove synchronous version of WriteOutput that accepts a string input (Shell) #1326
- BREAKING: Remove synchronous version of FilterOutput that accepts a string input (Shell) #1326
- Fixed a bug where error responses without schema would make generation fail #1272
- Fixed indeterministic parameters ordering #1358
- Fixed indeterministic error mappings ordering #1358
- Fixed indeterministic discriminator mapping ordering #1358
- Fixed non-deterministic parameters ordering #1358
- Fixed non-deterministic error mappings ordering #1358
- Fixed non-deterministic discriminator mapping ordering #1358
- Fixed race condition when removing child items leading to erratic code generation results #1358
- Replaced models namespaces flattening by circular properties trimming in Go #1358
- Fixed a bug where inherited interfaces would be missing imports in Go #1358
@ -1235,7 +1237,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixes a bug where generation would fail because of empty usings.
- Fixes a bug where Java and Go escaped model properties would not serialize properly.
- Fixes a bug where null values would not be added to additionalData if there was no matching property in dotnet.
- Fixes a bug where deserialzation of enums would throw an ArgumentException if the member didn't exist in dotnet.
- Fixes a bug where deserialization of enums would throw an ArgumentException if the member didn't exist in dotnet.
## [0.0.14] - 2021-11-08
@ -1273,7 +1275,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Renames middlewareoption into requestoption to stay agnostic from implementation #635
- Renames MiddlewareOption into RequestOption to stay agnostic from implementation #635
- Aligned http packages on naming convention #444
## [0.0.9] - 2021-10-01
@ -1306,7 +1308,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixes an issue where type could conflict with namespace names and prevent CSharp compilation #573
- Fixes an issue where primitive types would map to the wrong serialization method in dotnet #573
- Fixes an issue where union models would not be able to deserialize because of missing members #573
- Fixes an issue where request builder methods would refer to unexisting properties in dotnet #573
- Fixes an issue where request builder methods would refer to non-existent properties in dotnet #573
- Fixes an issue where duplicated symbols for different imports would make java compilation fail #573
- Adds missing type mappings in java #573
- Fixes an issue where Go generation could use reserved keywords #573
@ -1414,4 +1416,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial GitHub release

Просмотреть файл

@ -10,13 +10,13 @@
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.1" />
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.11.1" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.1" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.1" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.1" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.11.1" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.1" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.2" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.2" />
<Compile Remove="basic\**" />
</ItemGroup>

Просмотреть файл

@ -6,9 +6,9 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
github.com/microsoft/kiota-abstractions-go v1.6.1
github.com/microsoft/kiota-authentication-azure-go v1.1.0
github.com/microsoft/kiota-http-go v1.4.3
github.com/microsoft/kiota-http-go v1.4.4
github.com/microsoft/kiota-serialization-form-go v1.0.0
github.com/microsoft/kiota-serialization-json-go v1.0.7
github.com/microsoft/kiota-serialization-json-go v1.0.8
github.com/microsoft/kiota-serialization-multipart-go v1.0.0
github.com/microsoft/kiota-serialization-text-go v1.0.0
)

Просмотреть файл

@ -28,12 +28,12 @@ github.com/microsoft/kiota-abstractions-go v1.6.1 h1:NXK50S3BwJn9Wj6bO0YFuAig7y2
github.com/microsoft/kiota-abstractions-go v1.6.1/go.mod h1:FI1I2OHg0E7bK5t8DPnw+9C/CHVyLP6XeqDBT+95pTE=
github.com/microsoft/kiota-authentication-azure-go v1.1.0 h1:HudH57Enel9zFQ4TEaJw6lMiyZ5RbBdrRHwdU0NP2RY=
github.com/microsoft/kiota-authentication-azure-go v1.1.0/go.mod h1:zfPFOiLdEqM77Hua5B/2vpcXrVaGqSWjHSRzlvAWEgc=
github.com/microsoft/kiota-http-go v1.4.3 h1:BVviWZSZCm2nr9qySbhSXa8jlrLvCcC2/uV4p45Ow0I=
github.com/microsoft/kiota-http-go v1.4.3/go.mod h1:Kup5nMDD3a9sjdgRKHCqZWqtrv3FbprjcPaGjLR6FzM=
github.com/microsoft/kiota-http-go v1.4.4 h1:HM0KT/Q7o+JsGatFkkbTIqJL24Jzo5eMI5NNe9N4TQ4=
github.com/microsoft/kiota-http-go v1.4.4/go.mod h1:Kup5nMDD3a9sjdgRKHCqZWqtrv3FbprjcPaGjLR6FzM=
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.7 h1:yMbckSTPrjZdM4EMXgzLZSA3CtDaUBI350u0VoYRz7Y=
github.com/microsoft/kiota-serialization-json-go v1.0.7/go.mod h1:1krrY7DYl3ivPIzl4xTaBpew6akYNa8/Tal8g+kb0cc=
github.com/microsoft/kiota-serialization-json-go v1.0.8 h1:+aViv9k6wqaw1Fx6P49fl5GIB1hN3b6CG0McNTcUYBc=
github.com/microsoft/kiota-serialization-json-go v1.0.8/go.mod h1:O8+v11U0EUwHlCz7hrW38KxDmdhKAHfv4Q89uvsBalY=
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=

Просмотреть файл

@ -54,7 +54,7 @@ tomli==2.0.1 ; python_version < '3.11'
tomli-w==1.0.0 ; python_version >= '3.7'
tomlkit==0.13.0 ; python_version >= '3.7'
tomlkit==0.13.2 ; python_version >= '3.7'
typing-extensions==4.12.2 ; python_version >= '3.7'

72
it/typescript/package-lock.json сгенерированный
Просмотреть файл

@ -10,20 +10,20 @@
"license": "MIT",
"dependencies": {
"@azure/identity": "^4.4.1",
"@microsoft/kiota-abstractions": "^1.0.0-preview.59",
"@microsoft/kiota-authentication-azure": "^1.0.0-preview.54",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.58",
"@microsoft/kiota-serialization-form": "^1.0.0-preview.48",
"@microsoft/kiota-serialization-json": "^1.0.0-preview.59",
"@microsoft/kiota-serialization-multipart": "^1.0.0-preview.37",
"@microsoft/kiota-serialization-text": "^1.0.0-preview.56",
"@microsoft/kiota-abstractions": "^1.0.0-preview.61",
"@microsoft/kiota-authentication-azure": "^1.0.0-preview.56",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.60",
"@microsoft/kiota-serialization-form": "^1.0.0-preview.50",
"@microsoft/kiota-serialization-json": "^1.0.0-preview.61",
"@microsoft/kiota-serialization-multipart": "^1.0.0-preview.39",
"@microsoft/kiota-serialization-text": "^1.0.0-preview.58",
"express": "^4.19.2",
"node-fetch": "^2.7.0"
},
"devDependencies": {
"@es-exec/esbuild-plugin-start": "^0.0.5",
"@stylistic/eslint-plugin-ts": "^2.6.2",
"@types/node": "^22.2.0",
"@types/node": "^22.3.0",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"esbuild": "^0.23.0",
@ -751,9 +751,9 @@
}
},
"node_modules/@microsoft/kiota-abstractions": {
"version": "1.0.0-preview.59",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-abstractions/-/kiota-abstractions-1.0.0-preview.59.tgz",
"integrity": "sha512-qb+ZyYXa5BQhPtYPyySoAcsE56Elulm42b2E6J/VxG3TAFobZ8O0B1RcBPBRtnr5UbKW6a00f+DUL+8tiPYq8Q==",
"version": "1.0.0-preview.61",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-abstractions/-/kiota-abstractions-1.0.0-preview.61.tgz",
"integrity": "sha512-YTATU/NcZ+eG7pVO0EM3nDn3oKdZWzF53JAxpSQp5Uw3PZ/TmjBkRqdbEpCFYpWPXzhgX/z9AgGBM+zXcRgqnA==",
"dependencies": {
"@opentelemetry/api": "^1.7.0",
"@std-uritemplate/std-uritemplate": "^1.0.1",
@ -776,9 +776,9 @@
}
},
"node_modules/@microsoft/kiota-authentication-azure": {
"version": "1.0.0-preview.54",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-authentication-azure/-/kiota-authentication-azure-1.0.0-preview.54.tgz",
"integrity": "sha512-jIPz2ziwIKnrglynWmiXO0KcvRp3R0emHPXcSjbK+l7+D+kLrPZy92RDYjIdKJFtS39ZdM5jZgLeIEnmAkSvEQ==",
"version": "1.0.0-preview.56",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-authentication-azure/-/kiota-authentication-azure-1.0.0-preview.56.tgz",
"integrity": "sha512-pSKJ8SkNOUfleBei4l/ibLmzvu7w24CRpNtJNOHltSqUx+mB4TVynF67Gi+k2hO6ZuDSdkZZ0alBQVbpiOQIYg==",
"dependencies": {
"@azure/core-auth": "^1.5.0",
"@microsoft/kiota-abstractions": "*",
@ -787,9 +787,9 @@
}
},
"node_modules/@microsoft/kiota-http-fetchlibrary": {
"version": "1.0.0-preview.58",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-http-fetchlibrary/-/kiota-http-fetchlibrary-1.0.0-preview.58.tgz",
"integrity": "sha512-91Ft4hIt289rfwEP1R7WDsCd7tYJBKiCIRjGLlJ5jKcxamS4IHtI+ui8Qgy1tdk7azkq0+z6JzYZ6LBBdAJ97g==",
"version": "1.0.0-preview.60",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-http-fetchlibrary/-/kiota-http-fetchlibrary-1.0.0-preview.60.tgz",
"integrity": "sha512-uzWIcDlnMjmC9E31FzJ0FrM1VkwfWcSVm7PCm0waveQY9P4o+QAlcXX2Dtt/dPquxUQkVacbPqtuapa/MikFWg==",
"dependencies": {
"@microsoft/kiota-abstractions": "*",
"@opentelemetry/api": "^1.7.0",
@ -798,9 +798,9 @@
}
},
"node_modules/@microsoft/kiota-serialization-form": {
"version": "1.0.0-preview.48",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-form/-/kiota-serialization-form-1.0.0-preview.48.tgz",
"integrity": "sha512-NP95IzgLZcsCtBnlA21nPIM6qW0pqmWk3bv+S/pHFlb4bktfOrhrrfGGTMjPwq3Wpm7bGoQy/kr2iT8Y91sThQ==",
"version": "1.0.0-preview.50",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-form/-/kiota-serialization-form-1.0.0-preview.50.tgz",
"integrity": "sha512-H8T37KksMAkWe5vHNj9nCrhbuS2WloEGTr/gy4el2fz42Cwy5Ncb/vSrBYgquKl1t78NuVfIymqXqOB+cXG3GQ==",
"dependencies": {
"@microsoft/kiota-abstractions": "*",
"guid-typescript": "^1.0.9",
@ -808,9 +808,9 @@
}
},
"node_modules/@microsoft/kiota-serialization-json": {
"version": "1.0.0-preview.59",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-json/-/kiota-serialization-json-1.0.0-preview.59.tgz",
"integrity": "sha512-jqI9hozmP1S2YKfmAIIZpwMQREXdgWpAnGM/DgKSfs3O4fKmH4yVilhNRb6k+H+Y7TouS6cgTJkMnB10ARGY1A==",
"version": "1.0.0-preview.61",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-json/-/kiota-serialization-json-1.0.0-preview.61.tgz",
"integrity": "sha512-yB9XSbUozsx+X+bqM/7XxWAFZ5mPYbArV6ScnLVyMY7aXbrCV99NiZuuY67rlEWZ2BB0+nPYejRibXLDh62krQ==",
"dependencies": {
"@microsoft/kiota-abstractions": "*",
"guid-typescript": "^1.0.9",
@ -818,9 +818,9 @@
}
},
"node_modules/@microsoft/kiota-serialization-multipart": {
"version": "1.0.0-preview.37",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-multipart/-/kiota-serialization-multipart-1.0.0-preview.37.tgz",
"integrity": "sha512-PgRnMuk0dn2YxNgNt0o3ItjITJE5/M85u31IMe1z6U8hqnnYemJTIoXjXv1Tfv73qEfXy9USeAFaX8ioPe6rGA==",
"version": "1.0.0-preview.39",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-multipart/-/kiota-serialization-multipart-1.0.0-preview.39.tgz",
"integrity": "sha512-Hx+7eLRJGNKV+2Eu7Xm8V8IeUTkoTr7/g99G8Ul2MowsRX+UzFk2xBF4v/DAgdQhAQ44p1nwVV54mVI2JdQ+fw==",
"dependencies": {
"@microsoft/kiota-abstractions": "*",
"guid-typescript": "^1.0.9",
@ -828,9 +828,9 @@
}
},
"node_modules/@microsoft/kiota-serialization-text": {
"version": "1.0.0-preview.56",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-text/-/kiota-serialization-text-1.0.0-preview.56.tgz",
"integrity": "sha512-72UC5ACyYwMHNsy5+TyHk8Douw6uYrjCfZica00QlPmDO8+aW5yq1Ysr0A4ZL8B0LPU2P/SAYuKinBXpTkUA1w==",
"version": "1.0.0-preview.58",
"resolved": "https://registry.npmjs.org/@microsoft/kiota-serialization-text/-/kiota-serialization-text-1.0.0-preview.58.tgz",
"integrity": "sha512-7eMn3le/BelRL2rUCFmUJ3xxk6w45k9otYFM+p6GLygkjeGyMA0dDxnYCKFZBBAK0KACZQbI8zDamzLB/8O/PQ==",
"dependencies": {
"@microsoft/kiota-abstractions": "*",
"guid-typescript": "^1.0.9",
@ -955,12 +955,12 @@
"dev": true
},
"node_modules/@types/node": {
"version": "22.2.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz",
"integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==",
"version": "22.3.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.3.0.tgz",
"integrity": "sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==",
"dev": true,
"dependencies": {
"undici-types": "~6.13.0"
"undici-types": "~6.18.2"
}
},
"node_modules/@typescript-eslint/eslint-plugin": {
@ -3277,9 +3277,9 @@
}
},
"node_modules/undici-types": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz",
"integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==",
"version": "6.18.2",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz",
"integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==",
"dev": true
},
"node_modules/unpipe": {

Просмотреть файл

@ -20,7 +20,7 @@
"devDependencies": {
"@es-exec/esbuild-plugin-start": "^0.0.5",
"@stylistic/eslint-plugin-ts": "^2.6.2",
"@types/node": "^22.2.0",
"@types/node": "^22.3.0",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"esbuild": "^0.23.0",
@ -32,13 +32,13 @@
},
"dependencies": {
"@azure/identity": "^4.4.1",
"@microsoft/kiota-abstractions": "^1.0.0-preview.59",
"@microsoft/kiota-authentication-azure": "^1.0.0-preview.54",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.58",
"@microsoft/kiota-serialization-form": "^1.0.0-preview.48",
"@microsoft/kiota-serialization-json": "^1.0.0-preview.59",
"@microsoft/kiota-serialization-multipart": "^1.0.0-preview.37",
"@microsoft/kiota-serialization-text": "^1.0.0-preview.56",
"@microsoft/kiota-abstractions": "^1.0.0-preview.61",
"@microsoft/kiota-authentication-azure": "^1.0.0-preview.56",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.60",
"@microsoft/kiota-serialization-form": "^1.0.0-preview.50",
"@microsoft/kiota-serialization-json": "^1.0.0-preview.61",
"@microsoft/kiota-serialization-multipart": "^1.0.0-preview.39",
"@microsoft/kiota-serialization-text": "^1.0.0-preview.58",
"express": "^4.19.2",
"node-fetch": "^2.7.0"
}

Просмотреть файл

@ -39,18 +39,18 @@
<PackageReference Include="AsyncKeyedLock" Version="7.0.0" />
<PackageReference Include="DotNet.Glob" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.0" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.0" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.0" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.11.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.2" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.11.2" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.17" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.5-preview" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.17" />
<PackageReference Include="Microsoft.Plugins.Manifest" Version="0.0.7-preview" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.8" />
<PackageReference Include="YamlDotNet" Version="16.0.0" />
<ProjectReference Include="..\Kiota.Generated\KiotaGenerated.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

Просмотреть файл

@ -1599,14 +1599,14 @@ public partial class KiotaBuilder
TypeDefinition = codeDeclaration,
};
}
private CodeType CreateInheritedModelDeclarationAndType(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, string classNameSuffix, CodeNamespace codeNamespace, bool isRequestBody, string typeNameForInlineSchema)
private CodeType CreateInheritedModelDeclarationAndType(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, string classNameSuffix, CodeNamespace codeNamespace, bool isRequestBody, string typeNameForInlineSchema, bool isViaDiscriminator = false)
{
return new CodeType
{
TypeDefinition = CreateInheritedModelDeclaration(currentNode, schema, operation, classNameSuffix, codeNamespace, isRequestBody, typeNameForInlineSchema),
TypeDefinition = CreateInheritedModelDeclaration(currentNode, schema, operation, classNameSuffix, codeNamespace, isRequestBody, typeNameForInlineSchema, isViaDiscriminator),
};
}
private CodeClass CreateInheritedModelDeclaration(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, string classNameSuffix, CodeNamespace codeNamespace, bool isRequestBody, string typeNameForInlineSchema)
private CodeClass CreateInheritedModelDeclaration(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, OpenApiOperation? operation, string classNameSuffix, CodeNamespace codeNamespace, bool isRequestBody, string typeNameForInlineSchema, bool isViaDiscriminator = false)
{
var flattenedAllOfs = schema.AllOf.FlattenSchemaIfRequired(static x => x.AllOf).ToArray();
var referenceId = schema.Reference?.Id;
@ -1624,43 +1624,49 @@ public partial class KiotaBuilder
typeNameForInlineSchema :
currentNode.GetClassName(config.StructuredMimeTypes, operation: operation, suffix: classNameSuffix, schema: schema, requestBody: isRequestBody)))
.CleanupSymbolName();
var codeDeclaration = (rootSchemaHasProperties, inlineSchemas, referencedSchemas) switch
var codeDeclaration = (rootSchemaHasProperties, inlineSchemas, referencedSchemas, isViaDiscriminator) switch
{
// greatest parent type
(true, { Length: 0 }, { Length: 0 }) =>
(true, { Length: 0 }, { Length: 0 }, _) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace),
// inline schema + referenced schema
(false, { Length: > 0 }, { Length: 1 }) =>
(false, { Length: > 0 }, { Length: 1 }, _) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema.MergeAllOfSchemaEntries([.. referencedSchemas], static x => x.Reference is null)!, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, referencedSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, string.Empty)),
// properties + referenced schema
(true, { Length: 0 }, { Length: 1 }) =>
(true, { Length: 0 }, { Length: 1 }, _) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, referencedSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, string.Empty)),
// properties + inline schema
(true, { Length: 1 }, { Length: 0 }) =>
(true, { Length: 1 }, { Length: 0 }, _) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, inlineSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, typeNameForInlineSchema)),
// empty schema + referenced schema
(false, { Length: 0 }, { Length: 1 }) =>
(false, { Length: 0 }, { Length: 1 }, false) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, referencedSchemas[0], className, shortestNamespace),
// empty schema + inline schema
(false, { Length: 1 }, { Length: 0 }) =>
(false, { Length: 1 }, { Length: 0 }, false) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, inlineSchemas[0], className, shortestNamespace),
// empty schema + referenced schema and referenced by oneOf discriminator
(false, { Length: 0 }, { Length: 1 }, true) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, referencedSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, string.Empty)),
// empty schema + inline schema and referenced by oneOf discriminator
(false, { Length: 1 }, { Length: 0 }, true) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, inlineSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, typeNameForInlineSchema)),
// too much information but we can make a choice -> maps to properties + inline schema
(true, { Length: 1 }, { Length: 1 }) when inlineSchemas[0].HasAnyProperty() && !referencedSchemas[0].HasAnyProperty() =>
(true, { Length: 1 }, { Length: 1 }, _) when inlineSchemas[0].HasAnyProperty() && !referencedSchemas[0].HasAnyProperty() =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, inlineSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, typeNameForInlineSchema)),
// too much information but we can make a choice -> maps to properties + referenced schema
(true, { Length: 1 }, { Length: 1 }) when referencedSchemas[0].HasAnyProperty() && !inlineSchemas[0].HasAnyProperty() =>
(true, { Length: 1 }, { Length: 1 }, _) when referencedSchemas[0].HasAnyProperty() && !inlineSchemas[0].HasAnyProperty() =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, referencedSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, string.Empty)),
// too much information but we can merge root + inline schema
(true, { Length: 1 }, { Length: 1 }) when referencedSchemas[0].HasAnyProperty() && inlineSchemas[0].HasAnyProperty() && schema.MergeAllOfSchemaEntries([.. referencedSchemas]) is { } mergedSchema =>
(true, { Length: 1 }, { Length: 1 }, _) when referencedSchemas[0].HasAnyProperty() && inlineSchemas[0].HasAnyProperty() && schema.MergeAllOfSchemaEntries([.. referencedSchemas]) is { } mergedSchema =>
AddModelDeclarationIfDoesntExist(currentNode, operation, mergedSchema, className, shortestNamespace, CreateInheritedModelDeclaration(currentNode, referencedSchemas[0], operation, classNameSuffix, codeNamespace, isRequestBody, string.Empty)),
// none of the allOf entries have properties, it's a grandparent schema
(true, { Length: 1 }, { Length: 1 }) =>
(true, { Length: 1 }, { Length: 1 }, _) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema, className, shortestNamespace),
// too many entries, we mush everything together
(_, { Length: > 1 }, { Length: > 1 }) or (_, { Length: 0 or 1 }, { Length: > 1 }) or (_, { Length: > 1 }, { Length: 0 or 1 }) =>
(_, { Length: > 1 }, { Length: > 1 }, _) or (_, { Length: 0 or 1 }, { Length: > 1 }, _) or (_, { Length: > 1 }, { Length: 0 or 1 }, _) =>
AddModelDeclarationIfDoesntExist(currentNode, operation, schema.MergeAllOfSchemaEntries()!, className, shortestNamespace),
// meaningless scenario
(false, { Length: 0 }, { Length: 0 }) =>
(false, { Length: 0 }, { Length: 0 }, _) =>
throw new InvalidOperationException($"The type does not contain any information Path: {currentNode.Path}, Reference Id: {referenceId}"),
};
if (codeDeclaration is not CodeClass currentClass) throw new InvalidOperationException("Inheritance is only supported for classes");
@ -1735,7 +1741,7 @@ public partial class KiotaBuilder
className = $"{unionType.Name}Member{++membersWithNoName}";
var declarationType = new CodeType
{
TypeDefinition = AddModelDeclarationIfDoesntExist(currentNode, operation, currentSchema, className, shortestNamespace),
TypeDefinition = AddModelDeclarationIfDoesntExist(currentNode, operation, currentSchema, className, shortestNamespace, null),
CollectionKind = currentSchema.IsArray() ? CodeTypeBase.CodeTypeCollectionKind.Complex : default
};
if (!unionType.ContainsType(declarationType))
@ -1743,7 +1749,7 @@ public partial class KiotaBuilder
}
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, bool isViaDiscriminator = false)
{
var (codeNamespace, responseValue, suffix) = schema.IsReferencedSchema() switch
{
@ -1760,7 +1766,8 @@ public partial class KiotaBuilder
if (schema.IsInherited())
{
return CreateInheritedModelDeclarationAndType(currentNode, schema, operation, suffix, codeNamespace, isRequestBody, typeNameForInlineSchema);
// Pass isViaDiscriminator so that we can handle the special case where this model was referenced by a discriminator and we always want to generate a base class.
return CreateInheritedModelDeclarationAndType(currentNode, schema, operation, suffix, codeNamespace, isRequestBody, typeNameForInlineSchema, isViaDiscriminator);
}
if (schema.IsIntersection() && schema.MergeIntersectionSchemaEntries() is OpenApiSchema mergedSchema)
@ -1964,6 +1971,7 @@ public partial class KiotaBuilder
}
}
// Recurse into the discriminator & generate its referenced types
var mappings = GetDiscriminatorMappings(currentNode, schema, currentNamespace, newClass, currentOperation)
.Where(x => x.Value is { TypeDefinition: CodeClass definition } &&
definition.DerivesFrom(newClass)); // only the mappings that derive from the current class
@ -1973,6 +1981,7 @@ public partial class KiotaBuilder
}
private IEnumerable<KeyValuePair<string, CodeType>> GetDiscriminatorMappings(OpenApiUrlTreeNode currentNode, OpenApiSchema schema, CodeNamespace currentNamespace, CodeClass? baseClass, OpenApiOperation? currentOperation)
{
// Generate types that this discriminator references
return schema.GetDiscriminatorMappings(inheritanceIndex)
.Union(baseClass is not null && modelsNamespace is not null &&
(openApiDocument?.Components?.Schemas?.TryGetValue(baseClass.GetComponentSchemaName(modelsNamespace), out var componentSchema) ?? false) ?
@ -2160,7 +2169,8 @@ public partial class KiotaBuilder
logger.LogWarning("Discriminator {ComponentKey} not found in the OpenAPI document.", componentKey);
return null;
}
if (CreateModelDeclarations(currentNode, discriminatorSchema, currentOperation, GetShortestNamespace(currentNamespace, discriminatorSchema), string.Empty) is not CodeType result)
// Call CreateModelDeclarations with isViaDiscriminator=true. This is for a special case where we always generate a base class when types are referenced via a oneOf discriminator.
if (CreateModelDeclarations(currentNode, discriminatorSchema, currentOperation, GetShortestNamespace(currentNamespace, discriminatorSchema), string.Empty, null, string.Empty, false, true) is not CodeType result)
{
logger.LogWarning("Discriminator {ComponentKey} is not a valid model and points to a union type.", componentKey);
return null;

Просмотреть файл

@ -139,6 +139,7 @@ public class CodeFunctionWriter : BaseElementWriter<CodeFunction, TypeScriptConv
} param)
throw new InvalidOperationException("Interface parameter not found for code interface");
writer.StartBlock($"if ({param.Name.ToFirstCharacterLowerCase()}) {{");
if (codeInterface.StartBlock.Implements.FirstOrDefault(static x => x.TypeDefinition is CodeInterface) is CodeType inherits)
{
writer.WriteLine($"serialize{inherits.TypeDefinition!.Name.ToFirstCharacterUpperCase()}(writer, {param.Name.ToFirstCharacterLowerCase()})");
@ -151,6 +152,7 @@ public class CodeFunctionWriter : BaseElementWriter<CodeFunction, TypeScriptConv
if (codeInterface.GetPropertyOfKind(CodePropertyKind.AdditionalData) is CodeProperty additionalDataProperty)
writer.WriteLine($"writer.writeAdditionalData({codeInterface.Name.ToFirstCharacterLowerCase()}.{additionalDataProperty.Name.ToFirstCharacterLowerCase()});");
writer.CloseBlock();
}
private static bool IsCodePropertyCollectionOfEnum(CodeProperty property)

Просмотреть файл

@ -33,9 +33,13 @@ public class CodePropertyWriter : BaseElementWriter<CodeProperty, TypeScriptConv
case CodePropertyKind.RequestBuilder:
writer.WriteLine($"get {codeElement.Name.ToFirstCharacterLowerCase()}(): {returnType};");
break;
default:
case CodePropertyKind.QueryParameter:
case CodePropertyKind.AdditionalData:
writer.WriteLine($"{codeElement.Name.ToFirstCharacterLowerCase()}?: {returnType}{(isFlagEnum ? "[]" : string.Empty)};");
break;
default:
writer.WriteLine($"{codeElement.Name.ToFirstCharacterLowerCase()}?: {returnType}{(isFlagEnum ? "[]" : string.Empty)} | null;");
break;
}
}
}

Просмотреть файл

@ -58,6 +58,8 @@ public class TypeScriptConventionService : CommonLanguageConventionService
var paramType = GetTypeString(parameter.Type, targetElement);
var defaultValueSuffix = (string.IsNullOrEmpty(parameter.DefaultValue), parameter.Kind) switch
{
(false, CodeParameterKind.DeserializationTarget) when parameter.Parent is CodeMethod codeMethod && codeMethod.Kind is CodeMethodKind.Serializer
=> $" | null = {parameter.DefaultValue}",
(false, CodeParameterKind.DeserializationTarget) => $" = {parameter.DefaultValue}",
(false, _) => $" = {parameter.DefaultValue} as {paramType}",
(true, _) => string.Empty,

Просмотреть файл

@ -47,7 +47,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.5-preview" />
<PackageReference Include="StreamJsonRpc" Version="2.18.48" />
<PackageReference Include="StreamJsonRpc" Version="2.19.27" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="System.CommandLine.Rendering" Version="0.4.0-alpha.22272.1" />

Просмотреть файл

@ -7840,6 +7840,80 @@ components:
Assert.Single(groupClass.Properties.Where(static x => x.Name.Equals("facetprop1", StringComparison.OrdinalIgnoreCase)));
Assert.Single(groupClass.Properties.Where(static x => x.Name.Equals("facetprop2", StringComparison.OrdinalIgnoreCase)));
}
[Fact]
public async Task InheritanceWithAllOfBaseClassNoAdditionalProperties()
{
var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
await using var fs = await GetDocumentStream(@"openapi: 3.0.1
info:
title: OData Service for namespace microsoft.graph
description: This OData service is located at https://graph.microsoft.com/v1.0
version: 1.0.1
servers:
- url: https://graph.microsoft.com/v1.0
paths:
/directoryObject:
get:
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/microsoft.graph.directoryResult'
components:
schemas:
microsoft.graph.directoryResult:
required: ['fstype']
oneOf:
- $ref: '#/components/schemas/microsoft.graph.file'
- $ref: '#/components/schemas/microsoft.graph.folder'
- $ref: '#/components/schemas/microsoft.graph.link'
properties:
fstype:
type: string
discriminator:
propertyName: 'fstype'
mapping:
'file': '#/components/schemas/microsoft.graph.file'
'folder': '#/components/schemas/microsoft.graph.folder'
'link': '#/components/schemas/microsoft.graph.link'
microsoft.graph.baseDirectoryObject:
properties:
path:
type: string
microsoft.graph.file:
allOf:
- '$ref': '#/components/schemas/microsoft.graph.baseDirectoryObject'
microsoft.graph.folder:
allOf:
- '$ref': '#/components/schemas/microsoft.graph.baseDirectoryObject'
microsoft.graph.link:
allOf:
- '$ref': '#/components/schemas/microsoft.graph.baseDirectoryObject'
properties:
target:
type: string");
var mockLogger = new Mock<ILogger<KiotaBuilder>>();
var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", OpenAPIFilePath = tempFilePath }, _httpClient);
var document = await builder.CreateOpenApiDocumentAsync(fs);
var node = builder.CreateUriSpace(document);
var codeModel = builder.CreateSourceModel(node);
// Verify that all three classes referenced by the discriminator inherit from baseDirectoryObject
var folder = codeModel.FindChildByName<CodeClass>("Folder");
Assert.NotNull(folder.StartBlock.Inherits);
Assert.Equal("baseDirectoryObject", folder.StartBlock.Inherits.Name);
var file = codeModel.FindChildByName<CodeClass>("File");
Assert.NotNull(file.StartBlock.Inherits);
Assert.Equal("baseDirectoryObject", file.StartBlock.Inherits.Name);
var link = codeModel.FindChildByName<CodeClass>("Link");
Assert.NotNull(link.StartBlock.Inherits);
Assert.Equal("baseDirectoryObject", link.StartBlock.Inherits.Name);
}
[Fact]
public async Task NestedIntersectionTypeAllOf()
{

Просмотреть файл

@ -69,12 +69,12 @@ public sealed class CodePropertyWriterTests : IDisposable
Assert.DoesNotContain("?", result, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void WritesCustomProperty()
public void WritesCustomPropertyWithDefaultedNullType()
{
property.Kind = CodePropertyKind.Custom;
writer.Write(property);
var result = tw.ToString();
Assert.Contains($"{PropertyName}?: {TypeName}", result);
Assert.Contains($"{PropertyName}?: {TypeName} | null", result);
Assert.DoesNotContain("| undefined", result); // redundant with ?
}
[Fact]

14
vscode/microsoft-kiota/package-lock.json сгенерированный
Просмотреть файл

@ -547,12 +547,12 @@
"dev": true
},
"node_modules/@types/node": {
"version": "22.2.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz",
"integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==",
"version": "22.3.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.3.0.tgz",
"integrity": "sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==",
"dev": true,
"dependencies": {
"undici-types": "~6.13.0"
"undici-types": "~6.18.2"
}
},
"node_modules/@types/vscode": {
@ -4300,9 +4300,9 @@
}
},
"node_modules/undici-types": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz",
"integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==",
"version": "6.18.2",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz",
"integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==",
"dev": true
},
"node_modules/update-browserslist-db": {