diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 6eff961bac..d3ea8d16c9 100644
--- a/.github/workflows/docker.yml
+++ b/.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.7.0
+ uses: docker/build-push-action@v6.9.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.7.0
+ uses: docker/build-push-action@v6.9.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.7.0
+ uses: docker/build-push-action@v6.9.0
with:
push: true
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index b125148fae..29f5089976 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -22,17 +22,7 @@
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
- "problemMatcher": "$msCompile",
- "dependsOn": ["checkout:sample:locks"]
- },
- {
- "label": "checkout:sample:locks",
- "type": "process",
- "command": "git",
- "args": ["checkout", "**/kiota-lock.json"],
- "options": {
- "cwd": "${workspaceFolder}/samples"
- }
+ "problemMatcher": "$msCompile"
},
{
"label": "test",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a00ec3cb5f..61e9df9654 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
## [Unreleased]
### Added
+
- Control generated type access modifier for C# via `--type-access-modifier` flag. [#4788](https://github.com/microsoft/kiota/issues/4788)
### Changed
@@ -19,13 +20,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where a path segment named "item" after a single parameter path segment would derail generation. [#4814](https://github.com/microsoft/kiota/issues/4814)
- Fixed a bug where collection/array of primitive types members for union/intersection types would be ignored. [#5283](https://github.com/microsoft/kiota/issues/5283)
- Updated dependencies command and view to reflect the availability of bundles. [#5317](https://github.com/microsoft/kiota/issues/5317)
-- Fixed a when generating a plugin when only an operation is selected in the root node in the extension. [#5300](https://github.com/microsoft/kiota/issues/5300)
+- Fixed a bug when generating a plugin when only an operation is selected in the root node in the extension. [#5300](https://github.com/microsoft/kiota/issues/5300)
- Fixed a bug where function descriptions in plugin manifest defaults to path summary instead of description. [#5301](https://github.com/microsoft/kiota/issues/5301)
- Fixed a bug where TypeScript would not properly build URIs with uppercase first characters query parameter names.[#5382](https://github.com/microsoft/kiota/issues/5382)
-- Fixed a bug where the description special characters are encoded. [5286](https://github.com/microsoft/kiota/issues/5286)
+- Fixed a bug where the description special characters are encoded. [#5286](https://github.com/microsoft/kiota/issues/5286)
- Fixed a bug where python constructor parameters are being cast to strings leading to bugs as the types is unknown on graph call. [microsoftgraph/msgraph-sdk-python#165](https://github.com/microsoftgraph/msgraph-sdk-python/issues/165)
- Fixed a bug where child path segment from single parameter path segment would be incorrectly escaped. [#5433](https://github.com/microsoft/kiota/issues/5433)
-- Fixed inconsistent typing information generated for `ParsableFactory` and stream return types in python [kiota-abstractions-python#533](https://github.com/microsoft/kiota-abstractions-python/issues/333)
+- Fixed inconsistent typing information generated for `ParsableFactory` and stream return types in python [kiota-abstractions-python#533](https://github.com/microsoft/kiota-abstractions-python/issues/333)
+- Fixed a bug where untyped not imports in TypeScripts would not be erasable. [microsoft/kiota-typescript#1381](https://github.com/microsoft/kiota-typescript/issues/1381)
+- Updated schema link in plugin manifest to the correct url. [#5441](https://github.com/microsoft/kiota/issues/5441)
+- Removed registration of default serialization and deserialization classes in client constructor. [#5478](https://github.com/microsoft/kiota/pull/5478)
+- Fixed incorrect type name generation in aliased scenario in TS due to broad searching of types in root namespaces. [#5404](https://github.com/microsoft/kiota/issues/5404)
+- Fixed incorrect type mapping in request builders with subsequent paths with the same name. [#5462](https://github.com/microsoft/kiota/issues/5462)
- Fixed cyclic depencies in generated Go code. [#2834](https://github.com/microsoft/kiota/issues/2834)
## [1.18.0] - 2024-09-05
diff --git a/it/csharp/dotnet.csproj b/it/csharp/dotnet.csproj
index fa78b6c773..1c81728fc9 100644
--- a/it/csharp/dotnet.csproj
+++ b/it/csharp/dotnet.csproj
@@ -9,14 +9,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/it/java/pom.xml b/it/java/pom.xml
index f96904cfd1..b0a9bf1f90 100644
--- a/it/java/pom.xml
+++ b/it/java/pom.xml
@@ -15,7 +15,7 @@
UTF-8
UTF-8
- 1.4.0
+ 1.5.0
diff --git a/it/python/requirements-dev.txt b/it/python/requirements-dev.txt
index 4ce633c527..95548b7ce0 100644
--- a/it/python/requirements-dev.txt
+++ b/it/python/requirements-dev.txt
@@ -66,7 +66,7 @@ yapf==0.40.2
zipp==3.20.2 ; python_version >= '3.7'
-aiohttp==3.10.6 ; python_version >= '3.6'
+aiohttp==3.10.8 ; python_version >= '3.6'
aiosignal==1.3.1 ; python_version >= '3.7'
@@ -92,7 +92,7 @@ h2==4.1.0
hpack==4.0.0 ; python_full_version >= '3.6.1'
-httpcore==1.0.5 ; python_version >= '3.7'
+httpcore==1.0.6 ; python_version >= '3.7'
httpx[http2]==0.27.2
@@ -136,5 +136,5 @@ sniffio==1.3.1 ; python_version >= '3.7'
uritemplate==4.1.1 ; python_version >= '3.6'
-yarl==1.12.1 ; python_version >= '3.7'
+yarl==1.13.1 ; python_version >= '3.7'
diff --git a/it/typescript/package-lock.json b/it/typescript/package-lock.json
index 57aea33734..f9dd728763 100644
--- a/it/typescript/package-lock.json
+++ b/it/typescript/package-lock.json
@@ -23,9 +23,9 @@
"devDependencies": {
"@es-exec/esbuild-plugin-start": "^0.0.5",
"@stylistic/eslint-plugin-ts": "^2.8.0",
- "@types/node": "^22.7.0",
- "@typescript-eslint/eslint-plugin": "^8.7.0",
- "@typescript-eslint/parser": "^8.7.0",
+ "@types/node": "^22.7.4",
+ "@typescript-eslint/eslint-plugin": "^8.8.0",
+ "@typescript-eslint/parser": "^8.8.0",
"esbuild": "^0.24.0",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
@@ -948,25 +948,25 @@
"dev": true
},
"node_modules/@types/node": {
- "version": "22.7.0",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.0.tgz",
- "integrity": "sha512-MOdOibwBs6KW1vfqz2uKMlxq5xAfAZ98SZjO8e3XnAbFnTJtAspqhWk7hrdSAs9/Y14ZWMiy7/MxMUzAOadYEw==",
+ "version": "22.7.4",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz",
+ "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==",
"dev": true,
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/@typescript-eslint/eslint-plugin": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.7.0.tgz",
- "integrity": "sha512-RIHOoznhA3CCfSTFiB6kBGLQtB/sox+pJ6jeFu6FxJvqL8qRxq/FfGO/UhsGgQM9oGdXkV4xUgli+dt26biB6A==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz",
+ "integrity": "sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
- "@typescript-eslint/scope-manager": "8.7.0",
- "@typescript-eslint/type-utils": "8.7.0",
- "@typescript-eslint/utils": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0",
+ "@typescript-eslint/scope-manager": "8.8.0",
+ "@typescript-eslint/type-utils": "8.8.0",
+ "@typescript-eslint/utils": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0",
"graphemer": "^1.4.0",
"ignore": "^5.3.1",
"natural-compare": "^1.4.0",
@@ -990,15 +990,15 @@
}
},
"node_modules/@typescript-eslint/parser": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.7.0.tgz",
- "integrity": "sha512-lN0btVpj2unxHlNYLI//BQ7nzbMJYBVQX5+pbNXvGYazdlgYonMn4AhhHifQ+J4fGRYA/m1DjaQjx+fDetqBOQ==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.0.tgz",
+ "integrity": "sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==",
"dev": true,
"dependencies": {
- "@typescript-eslint/scope-manager": "8.7.0",
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/typescript-estree": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0",
+ "@typescript-eslint/scope-manager": "8.8.0",
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/typescript-estree": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0",
"debug": "^4.3.4"
},
"engines": {
@@ -1018,13 +1018,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.7.0.tgz",
- "integrity": "sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz",
+ "integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0"
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -1035,13 +1035,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.7.0.tgz",
- "integrity": "sha512-tl0N0Mj3hMSkEYhLkjREp54OSb/FI6qyCzfiiclvJvOqre6hsZTGSnHtmFLDU8TIM62G7ygEa1bI08lcuRwEnQ==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.0.tgz",
+ "integrity": "sha512-IKwJSS7bCqyCeG4NVGxnOP6lLT9Okc3Zj8hLO96bpMkJab+10HIfJbMouLrlpyOr3yrQ1cA413YPFiGd1mW9/Q==",
"dev": true,
"dependencies": {
- "@typescript-eslint/typescript-estree": "8.7.0",
- "@typescript-eslint/utils": "8.7.0",
+ "@typescript-eslint/typescript-estree": "8.8.0",
+ "@typescript-eslint/utils": "8.8.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.3.0"
},
@@ -1059,9 +1059,9 @@
}
},
"node_modules/@typescript-eslint/types": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.7.0.tgz",
- "integrity": "sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz",
+ "integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==",
"dev": true,
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -1072,13 +1072,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.7.0.tgz",
- "integrity": "sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz",
+ "integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0",
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
@@ -1124,15 +1124,15 @@
}
},
"node_modules/@typescript-eslint/utils": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.7.0.tgz",
- "integrity": "sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.0.tgz",
+ "integrity": "sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
- "@typescript-eslint/scope-manager": "8.7.0",
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/typescript-estree": "8.7.0"
+ "@typescript-eslint/scope-manager": "8.8.0",
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/typescript-estree": "8.8.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -1146,12 +1146,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.7.0.tgz",
- "integrity": "sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz",
+ "integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "8.7.0",
+ "@typescript-eslint/types": "8.8.0",
"eslint-visitor-keys": "^3.4.3"
},
"engines": {
diff --git a/it/typescript/package.json b/it/typescript/package.json
index b8e09534e7..d27d9f41b8 100644
--- a/it/typescript/package.json
+++ b/it/typescript/package.json
@@ -20,9 +20,9 @@
"devDependencies": {
"@es-exec/esbuild-plugin-start": "^0.0.5",
"@stylistic/eslint-plugin-ts": "^2.8.0",
- "@types/node": "^22.7.0",
- "@typescript-eslint/eslint-plugin": "^8.7.0",
- "@typescript-eslint/parser": "^8.7.0",
+ "@types/node": "^22.7.4",
+ "@typescript-eslint/eslint-plugin": "^8.8.0",
+ "@typescript-eslint/parser": "^8.8.0",
"esbuild": "^0.24.0",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
diff --git a/src/Kiota.Builder/Kiota.Builder.csproj b/src/Kiota.Builder/Kiota.Builder.csproj
index dd14cbd848..96912deaca 100644
--- a/src/Kiota.Builder/Kiota.Builder.csproj
+++ b/src/Kiota.Builder/Kiota.Builder.csproj
@@ -38,22 +38,22 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs
index 4978a47ec5..d575562412 100644
--- a/src/Kiota.Builder/KiotaBuilder.cs
+++ b/src/Kiota.Builder/KiotaBuilder.cs
@@ -956,7 +956,10 @@ x.Parent is CodeIndexer ||
Parallel.ForEach(unmappedRequestBuilderTypes, parallelOptions, x =>
{
var parentNS = x.Parent?.Parent?.Parent as CodeNamespace;
- x.TypeDefinition = parentNS?.FindChildrenByName(x.Name).MinBy(shortestNamespaceOrder);
+ CodeClass[] exceptions = x.Parent?.Parent is CodeClass parentClass ? [parentClass] : [];
+ x.TypeDefinition = parentNS?.FindChildrenByName(x.Name)
+ .Except(exceptions)// the property method should not reference itself as a return type.
+ .MinBy(shortestNamespaceOrder);
// searching down first because most request builder properties on a request builder are just sub paths on the API
if (x.TypeDefinition == null)
{
diff --git a/src/Kiota.Builder/Plugins/PluginsGenerationService.cs b/src/Kiota.Builder/Plugins/PluginsGenerationService.cs
index e91a2b87ae..4ec587549b 100644
--- a/src/Kiota.Builder/Plugins/PluginsGenerationService.cs
+++ b/src/Kiota.Builder/Plugins/PluginsGenerationService.cs
@@ -9,7 +9,6 @@
using Kiota.Builder.Configuration;
using Kiota.Builder.Extensions;
using Kiota.Builder.OpenApiExtensions;
-using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.OpenApi.ApiManifest;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Services;
@@ -82,7 +81,7 @@ public async Task GenerateManifestAsync(CancellationToken cancellationToken = de
case PluginType.APIManifest:
var apiManifest = new ApiManifestDocument("application"); //TODO add application name
// pass empty config hash so that its not included in this manifest.
- apiManifest.ApiDependencies.AddOrReplace(Configuration.ClientClassName, Configuration.ToApiDependency(string.Empty, TreeNode?.GetRequestInfo().ToDictionary(static x => x.Key, static x => x.Value) ?? [], WorkingDirectory));
+ apiManifest.ApiDependencies[Configuration.ClientClassName] = Configuration.ToApiDependency(string.Empty, TreeNode?.GetRequestInfo().ToDictionary(static x => x.Key, static x => x.Value) ?? [], WorkingDirectory);
var publisherName = string.IsNullOrEmpty(OAIDocument.Info?.Contact?.Name)
? DefaultContactName
: OAIDocument.Info.Contact.Name;
@@ -183,7 +182,7 @@ private static OpenApiDocument InlineRequestBodyAllOf(OpenApiDocument openApiDoc
{
foreach (var property in apiSchema.Properties)
{
- newSchema.Properties.Add(property.Key, property.Value);
+ newSchema.Properties.TryAdd(property.Key, property.Value);
}
}
if (apiSchema.MaxProperties is not null) newSchema.MaxProperties = apiSchema.MaxProperties;
@@ -264,7 +263,7 @@ private PluginManifestDocument GetManifestDocument(string openApiDocumentPath)
var manifestInfo = ExtractInfoFromDocument(OAIDocument.Info);
var pluginManifestDocument = new PluginManifestDocument
{
- Schema = "https://aka.ms/json-schemas/copilot-extensions/v2.1/plugin.schema.json",
+ Schema = "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.1/schema.json",
SchemaVersion = "v2.1",
NameForHuman = OAIDocument.Info?.Title.CleanupXMLString(),
DescriptionForHuman = descriptionForHuman,
diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
index e4e49305a1..825c94a1c3 100644
--- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
+++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
@@ -728,7 +728,10 @@ private static bool HasMultipartBody(CodeMethod m) =>
AbstractionsPackageName, MultipartBodyClassName, $"serialize{MultipartBodyClassName}"),
new (static x => (x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Custom) && prop.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase))
|| (x is CodeMethod method && (method.Parameters.Any(param => param.Kind is CodeParameterKind.RequestBody && param.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)) || method.ReturnType.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase))),
- AbstractionsPackageName, KiotaBuilder.UntypedNodeName, "createUntypedNodeFromDiscriminatorValue"),
+ AbstractionsPackageName, "createUntypedNodeFromDiscriminatorValue"),
+ new (static x => (x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.Custom) && prop.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase))
+ || (x is CodeMethod method && (method.Parameters.Any(param => param.Kind is CodeParameterKind.RequestBody && param.Type.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase)) || method.ReturnType.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase))),
+ AbstractionsPackageName, true, KiotaBuilder.UntypedNodeName),
};
private const string MultipartBodyClassName = "MultipartBody";
private static void CorrectImplements(ProprietableBlockDeclaration block)
diff --git a/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs b/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs
index 1b3b2b22e8..ebb98ab309 100644
--- a/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs
+++ b/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs
@@ -295,9 +295,9 @@ public static string GetFactoryMethodName(CodeTypeBase targetClassType, CodeElem
throw new InvalidOperationException($"Unable to find factory method for {targetClassType}");
}
- private static CodeFunction? GetFactoryMethod(CodeInterface definitionClass, string factoryMethodName)
+ internal static CodeFunction? GetFactoryMethod(CodeInterface definitionClass, string factoryMethodName)
{
- return definitionClass.GetImmediateParentOfType(definitionClass)?.FindChildByName(factoryMethodName);
+ return definitionClass.GetImmediateParentOfType(definitionClass)?.FindChildByName(factoryMethodName);
}
public string GetDeserializationMethodName(CodeTypeBase codeType, CodeMethod method, bool? IsCollection = null)
diff --git a/src/kiota/Handlers/Client/GenerateHandler.cs b/src/kiota/Handlers/Client/GenerateHandler.cs
index 9911911515..7c9ce9d01a 100644
--- a/src/kiota/Handlers/Client/GenerateHandler.cs
+++ b/src/kiota/Handlers/Client/GenerateHandler.cs
@@ -53,7 +53,6 @@ public override async Task InvokeAsync(InvocationContext context)
var generationConfiguration = new GenerationConfiguration();
var requests = !refresh && manifest is not null && manifest.ApiDependencies.TryGetValue(clientEntry.Key, out var value) ? value.Requests : [];
clientEntry.Value.UpdateGenerationConfigurationFromApiClientConfiguration(generationConfiguration, clientEntry.Key, requests);
- DefaultSerializersAndDeserializers(generationConfiguration);
generationConfiguration.ClearCache = refresh;
generationConfiguration.CleanOutput = refresh;
generationConfiguration.Operation = ConsumerOperation.Generate;
diff --git a/src/kiota/kiota.csproj b/src/kiota/kiota.csproj
index cf3a01e8bb..1bc679f1a4 100644
--- a/src/kiota/kiota.csproj
+++ b/src/kiota/kiota.csproj
@@ -47,7 +47,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj b/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj
index 6f0f2b2342..e0797c6855 100644
--- a/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj
+++ b/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj
@@ -17,7 +17,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj b/tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj
index ba86766df8..5f6c96fe13 100644
--- a/tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj
+++ b/tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj
@@ -19,7 +19,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
index a38146b19a..6b17ad738e 100644
--- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
+++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
@@ -231,6 +231,74 @@ await File.WriteAllTextAsync(tempFilePath, @$"openapi: 3.0.1
Assert.NotNull(specializedNS.FindChildByName("StorageAccount", false));
}
[Fact]
+ public async Task HandlesPathWithRepeatedSegment()
+ {
+ var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
+ await File.WriteAllTextAsync(tempFilePath, @$"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://api.funtranslations.com
+paths:
+ /media/response/response/{{id}}:
+ get:
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/MediaResponseModel'
+components:
+ schemas:
+ MediaResponseModel:
+ type: object
+ properties:
+ name:
+ type: string
+ id:
+ type: string
+ format: uuid
+ mediaType:
+ type: string
+ url:
+ type: string");
+ var mockLogger = new Mock>();
+ var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration
+ {
+ ClientClassName = "Graph",
+ OpenAPIFilePath = "https://api.apis.guru/v2/specs/funtranslations.com/starwars/2.3/swagger.json"
+ }, _httpClient);
+ await using var fs = new FileStream(tempFilePath, FileMode.Open);
+ var document = await builder.CreateOpenApiDocumentAsync(fs);
+ var node = builder.CreateUriSpace(document);
+ builder.SetApiRootUrl();
+ var codeModel = builder.CreateSourceModel(node);
+ var rootNS = codeModel.FindNamespaceByName("ApiSdk");
+ Assert.NotNull(rootNS);
+ var responseBuilderNs = codeModel.FindNamespaceByName("ApiSdk.media.response");
+ Assert.NotNull(responseBuilderNs);
+ var responseRequestBuilder = responseBuilderNs.FindChildByName("ResponseRequestBuilder", false);
+ Assert.NotNull(responseRequestBuilder);
+ var navigationProperty = responseRequestBuilder.Properties.FirstOrDefault(prop =>
+ prop.IsOfKind(CodePropertyKind.RequestBuilder) &&
+ prop.Name.Equals("Response", StringComparison.OrdinalIgnoreCase));
+ Assert.NotNull(navigationProperty);
+ var navigationPropertyType = navigationProperty.Type as CodeType;
+ Assert.NotNull(navigationPropertyType);
+ Assert.NotEqual(responseRequestBuilder, navigationPropertyType.TypeDefinition);// the request builder should not be the same as the class it is in.
+ var nestedResponseBuilderNs = codeModel.FindNamespaceByName("ApiSdk.media.response.response");
+ var nestedResponseRequestBuilder = nestedResponseBuilderNs.FindChildByName("ResponseRequestBuilder", false);
+ Assert.Equal(nestedResponseRequestBuilder, navigationPropertyType.TypeDefinition);// the request builder should not be the same as the class it is in.
+ }
+ [Fact]
public async Task HandlesPathWithItemInNameSegment()
{
var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
diff --git a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
index 44a4697314..c55fdb3ade 100644
--- a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
+++ b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
@@ -604,6 +604,26 @@ public static TheoryData>
Assert.Equal(3, schema.Properties.Count);
}
},
+ // objects with repeated properties
+ {
+ """
+ content:
+ application/json:
+ schema:
+ allOf: [
+ {type: object, properties: {a: {type: string}, b: {type: number}}},
+ {type: object, properties: {b: {type: number}}}
+ ]
+ """, (slicedDocument, _) =>
+ {
+ Assert.NotNull(slicedDocument);
+ Assert.NotEmpty(slicedDocument.Paths);
+ var schema = slicedDocument.Paths["/test"].Operations[OperationType.Post].RequestBody
+ .Content["application/json"].Schema;
+ Assert.Equal("object", schema.Type);
+ Assert.Equal(2, schema.Properties.Count);
+ }
+ },
// AnyOf
{
"""
diff --git a/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs b/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs
index f26cbb41e8..540f49f10d 100644
--- a/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs
+++ b/tests/Kiota.Builder.Tests/Refiners/TypeScriptLanguageRefinerTests.cs
@@ -594,6 +594,82 @@ public async Task AliasesDuplicateUsingSymbolsAsync()
Assert.DoesNotContain(modelInterface.Usings, x => x.Declaration?.TypeDefinition == source2Interface);
Assert.DoesNotContain(modelInterface.Usings, x => x.Declaration?.TypeDefinition == source1Interface);
}
+
+ [Fact]
+ public async Task AliasesDuplicateUsingSymbolsAsyncWithAliasedReferencesToParentNamespaceAsync()
+ {
+ var generationConfiguration = new GenerationConfiguration { Language = GenerationLanguage.TypeScript };
+ var source1 = TestHelper.CreateModelClassInModelsNamespace(generationConfiguration, root, "source");
+ var modelsNS = root.FindNamespaceByName(generationConfiguration.ModelsNamespaceName);
+ Assert.NotNull(modelsNS);
+ var submodelsNS = modelsNS.AddNamespace($"{generationConfiguration.ModelsNamespaceName}.submodels");
+ var source2 = TestHelper.CreateModelClass(submodelsNS, "source");
+ var model = TestHelper.CreateModelClass(submodelsNS, "model");
+
+ var source1Factory = new CodeMethod
+ {
+ Name = "factory",
+ Kind = CodeMethodKind.Factory,
+ IsAsync = false,
+ IsStatic = true,
+ ReturnType = new CodeType { Name = "source", TypeDefinition = source2, },
+ };
+ source1.AddMethod(source1Factory);
+
+ var using1 = new CodeUsing
+ {
+ Name = modelsNS.Name,
+ Declaration = new CodeType
+ {
+ Name = source1.Name,
+ TypeDefinition = source1,
+ IsExternal = false,
+ }
+ };
+
+ var source2Factory = new CodeMethod
+ {
+ Name = "factory",
+ Kind = CodeMethodKind.Factory,
+ IsAsync = false,
+ IsStatic = true,
+ ReturnType = new CodeType { Name = "source", TypeDefinition = source2 },
+ };
+
+ source2.AddMethod(source2Factory);
+ var using2 = new CodeUsing
+ {
+ Name = submodelsNS.Name,
+ Declaration = new CodeType
+ {
+ Name = source2.Name,
+ TypeDefinition = source2,
+ IsExternal = false,
+ }
+ };
+ model.AddUsing(using1);
+ var property1 = new CodeProperty { Name = "source1", Type = new CodeType { TypeDefinition = source1, } };
+ model.AddProperty(property1);
+ var property2 = new CodeProperty { Name = "source2", Type = new CodeType { TypeDefinition = source2, } };
+ model.AddProperty(property2);
+ model.AddUsing(using2);
+ await ILanguageRefiner.RefineAsync(new GenerationConfiguration { Language = GenerationLanguage.TypeScript }, root);
+
+ var sourceCodeFile = modelsNS.FindChildByName(IndexFileName, false);
+ Assert.NotNull(sourceCodeFile);
+ var source1Interface = sourceCodeFile.Interfaces.First(x => x.Name == source1.Name.ToFirstCharacterUpperCase());
+
+ var modelCodeFile = submodelsNS.FindChildByName(IndexFileName, false);
+ Assert.NotNull(modelCodeFile);
+ var source2Interface = modelCodeFile.Interfaces.First(x => x.Name == source1.Name.ToFirstCharacterUpperCase());
+
+ var result1 = Kiota.Builder.Writers.TypeScript.TypeScriptConventionService.GetFactoryMethod(source1Interface, "createSourceFromDiscriminatorValue");
+ Assert.NotNull(result1);
+ var result2 = Kiota.Builder.Writers.TypeScript.TypeScriptConventionService.GetFactoryMethod(source2Interface, "createSourceFromDiscriminatorValue");
+ Assert.NotNull(result2);
+ Assert.NotEqual(result1, result2);// they should be different discriminators despite having the same name
+ }
+
[Fact]
public async Task DoesNotKeepCancellationParametersInRequestExecutorsAsync()
{
diff --git a/tests/Kiota.Tests/Kiota.Tests.csproj b/tests/Kiota.Tests/Kiota.Tests.csproj
index 9977c1f6ad..2ab181470b 100644
--- a/tests/Kiota.Tests/Kiota.Tests.csproj
+++ b/tests/Kiota.Tests/Kiota.Tests.csproj
@@ -12,7 +12,7 @@
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json
index 45aee533a2..6332e8af7c 100644
--- a/vscode/microsoft-kiota/package-lock.json
+++ b/vscode/microsoft-kiota/package-lock.json
@@ -22,15 +22,15 @@
"@types/mocha": "^10.0.8",
"@types/node": "22.x",
"@types/vscode": "^1.93.0",
- "@typescript-eslint/eslint-plugin": "^8.7.0",
- "@typescript-eslint/parser": "^8.7.0",
+ "@typescript-eslint/eslint-plugin": "^8.8.0",
+ "@typescript-eslint/parser": "^8.8.0",
"@vscode/test-electron": "^2.4.1",
"eslint": "^9.11.1",
"glob": "^11.0.0",
"mocha": "^10.7.3",
"ts-loader": "^9.5.1",
"typescript": "^5.6.2",
- "webpack": "^5.94.0",
+ "webpack": "^5.95.0",
"webpack-cli": "^5.1.4"
},
"engines": {
@@ -531,9 +531,9 @@
"dev": true
},
"node_modules/@types/node": {
- "version": "22.7.0",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.0.tgz",
- "integrity": "sha512-MOdOibwBs6KW1vfqz2uKMlxq5xAfAZ98SZjO8e3XnAbFnTJtAspqhWk7hrdSAs9/Y14ZWMiy7/MxMUzAOadYEw==",
+ "version": "22.7.4",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz",
+ "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==",
"dev": true,
"dependencies": {
"undici-types": "~6.19.2"
@@ -546,16 +546,16 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.7.0.tgz",
- "integrity": "sha512-RIHOoznhA3CCfSTFiB6kBGLQtB/sox+pJ6jeFu6FxJvqL8qRxq/FfGO/UhsGgQM9oGdXkV4xUgli+dt26biB6A==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz",
+ "integrity": "sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
- "@typescript-eslint/scope-manager": "8.7.0",
- "@typescript-eslint/type-utils": "8.7.0",
- "@typescript-eslint/utils": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0",
+ "@typescript-eslint/scope-manager": "8.8.0",
+ "@typescript-eslint/type-utils": "8.8.0",
+ "@typescript-eslint/utils": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0",
"graphemer": "^1.4.0",
"ignore": "^5.3.1",
"natural-compare": "^1.4.0",
@@ -579,15 +579,15 @@
}
},
"node_modules/@typescript-eslint/parser": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.7.0.tgz",
- "integrity": "sha512-lN0btVpj2unxHlNYLI//BQ7nzbMJYBVQX5+pbNXvGYazdlgYonMn4AhhHifQ+J4fGRYA/m1DjaQjx+fDetqBOQ==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.0.tgz",
+ "integrity": "sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==",
"dev": true,
"dependencies": {
- "@typescript-eslint/scope-manager": "8.7.0",
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/typescript-estree": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0",
+ "@typescript-eslint/scope-manager": "8.8.0",
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/typescript-estree": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0",
"debug": "^4.3.4"
},
"engines": {
@@ -607,13 +607,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.7.0.tgz",
- "integrity": "sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz",
+ "integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0"
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -624,13 +624,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.7.0.tgz",
- "integrity": "sha512-tl0N0Mj3hMSkEYhLkjREp54OSb/FI6qyCzfiiclvJvOqre6hsZTGSnHtmFLDU8TIM62G7ygEa1bI08lcuRwEnQ==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.0.tgz",
+ "integrity": "sha512-IKwJSS7bCqyCeG4NVGxnOP6lLT9Okc3Zj8hLO96bpMkJab+10HIfJbMouLrlpyOr3yrQ1cA413YPFiGd1mW9/Q==",
"dev": true,
"dependencies": {
- "@typescript-eslint/typescript-estree": "8.7.0",
- "@typescript-eslint/utils": "8.7.0",
+ "@typescript-eslint/typescript-estree": "8.8.0",
+ "@typescript-eslint/utils": "8.8.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.3.0"
},
@@ -648,9 +648,9 @@
}
},
"node_modules/@typescript-eslint/types": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.7.0.tgz",
- "integrity": "sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz",
+ "integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==",
"dev": true,
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -661,13 +661,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.7.0.tgz",
- "integrity": "sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz",
+ "integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/visitor-keys": "8.7.0",
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/visitor-keys": "8.8.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
@@ -713,15 +713,15 @@
}
},
"node_modules/@typescript-eslint/utils": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.7.0.tgz",
- "integrity": "sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.0.tgz",
+ "integrity": "sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
- "@typescript-eslint/scope-manager": "8.7.0",
- "@typescript-eslint/types": "8.7.0",
- "@typescript-eslint/typescript-estree": "8.7.0"
+ "@typescript-eslint/scope-manager": "8.8.0",
+ "@typescript-eslint/types": "8.8.0",
+ "@typescript-eslint/typescript-estree": "8.8.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -735,12 +735,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
- "version": "8.7.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.7.0.tgz",
- "integrity": "sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==",
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz",
+ "integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==",
"dev": true,
"dependencies": {
- "@typescript-eslint/types": "8.7.0",
+ "@typescript-eslint/types": "8.8.0",
"eslint-visitor-keys": "^3.4.3"
},
"engines": {
@@ -4295,9 +4295,9 @@
}
},
"node_modules/webpack": {
- "version": "5.94.0",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.94.0.tgz",
- "integrity": "sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg==",
+ "version": "5.95.0",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz",
+ "integrity": "sha512-2t3XstrKULz41MNMBF+cJ97TyHdyQ8HCt//pqErqDvNjU9YQBnZxIHa11VXsi7F3mb5/aO2tuDxdeTPdU7xu9Q==",
"dev": true,
"dependencies": {
"@types/estree": "^1.0.5",
diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json
index ee815cc95c..9c6283c730 100644
--- a/vscode/microsoft-kiota/package.json
+++ b/vscode/microsoft-kiota/package.json
@@ -471,15 +471,15 @@
"@types/mocha": "^10.0.8",
"@types/node": "22.x",
"@types/vscode": "^1.93.0",
- "@typescript-eslint/eslint-plugin": "^8.7.0",
- "@typescript-eslint/parser": "^8.7.0",
+ "@typescript-eslint/eslint-plugin": "^8.8.0",
+ "@typescript-eslint/parser": "^8.8.0",
"@vscode/test-electron": "^2.4.1",
"eslint": "^9.11.1",
"glob": "^11.0.0",
"mocha": "^10.7.3",
"ts-loader": "^9.5.1",
"typescript": "^5.6.2",
- "webpack": "^5.94.0",
+ "webpack": "^5.95.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
diff --git a/vscode/microsoft-kiota/src/commands/Command.ts b/vscode/microsoft-kiota/src/commands/Command.ts
new file mode 100644
index 0000000000..eee2b170bd
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/Command.ts
@@ -0,0 +1,5 @@
+export abstract class Command {
+ public abstract getName(): string;
+
+ public abstract execute(args: unknown): Promise;
+}
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/commands/migrateFromLockFileCommand.ts b/vscode/microsoft-kiota/src/commands/migrateFromLockFileCommand.ts
new file mode 100644
index 0000000000..a534f460fc
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/migrateFromLockFileCommand.ts
@@ -0,0 +1,30 @@
+import * as vscode from "vscode";
+import { ExtensionContext, Uri, workspace } from "vscode";
+
+import { extensionId } from "../constants";
+import { Command } from "./Command";
+import { handleMigration } from "../util";
+
+export class MigrateFromLockFileCommand extends Command {
+ private _context: ExtensionContext;
+
+ constructor(context: ExtensionContext) {
+ super();
+ this._context = context;
+ }
+
+ public getName(): string {
+ return `${extensionId}.migrateFromLockFile`;
+ }
+
+ public async execute(uri: Uri): Promise {
+ const workspaceFolder = workspace.getWorkspaceFolder(uri);
+
+ if (!workspaceFolder) {
+ vscode.window.showErrorMessage(vscode.l10n.t("Could not determine the workspace folder."));
+ return;
+ }
+
+ await handleMigration(this._context, workspaceFolder);
+ }
+}
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-view/addAllToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-view/addAllToSelectedEndpointsCommand.ts
new file mode 100644
index 0000000000..1f1bdb869b
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/open-api-tree-view/addAllToSelectedEndpointsCommand.ts
@@ -0,0 +1,20 @@
+import { treeViewId } from "../../constants";
+import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
+import { Command } from "../Command";
+
+export class AddAllToSelectedEndpointsCommand extends Command {
+ private _openApiTreeProvider: OpenApiTreeProvider;
+
+ constructor(openApiTreeProvider: OpenApiTreeProvider) {
+ super();
+ this._openApiTreeProvider = openApiTreeProvider;
+ }
+
+ public getName(): string {
+ return `${treeViewId}.addAllToSelectedEndpoints`;
+ }
+
+ public async execute(openApiTreeNode: OpenApiTreeNode): Promise {
+ this._openApiTreeProvider.select(openApiTreeNode, true, true);
+ }
+}
diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-view/addToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-view/addToSelectedEndpointsCommand.ts
new file mode 100644
index 0000000000..fcfad7f51f
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/open-api-tree-view/addToSelectedEndpointsCommand.ts
@@ -0,0 +1,20 @@
+import { treeViewId } from "../../constants";
+import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
+import { Command } from "../Command";
+
+export class AddToSelectedEndpointsCommand extends Command {
+ private _openApiTreeProvider: OpenApiTreeProvider;
+
+ constructor(openApiTreeProvider: OpenApiTreeProvider) {
+ super();
+ this._openApiTreeProvider = openApiTreeProvider;
+ }
+
+ public getName(): string {
+ return `${treeViewId}.addToSelectedEndpoints`;
+ }
+
+ public async execute(openApiTreeNode: OpenApiTreeNode): Promise {
+ this._openApiTreeProvider.select(openApiTreeNode, true, false);
+ }
+}
diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-view/filterDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-view/filterDescriptionCommand.ts
new file mode 100644
index 0000000000..73a80115ac
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/open-api-tree-view/filterDescriptionCommand.ts
@@ -0,0 +1,24 @@
+import { treeViewId } from "../../constants";
+import { OpenApiTreeProvider } from "../../openApiTreeProvider";
+import { filterSteps } from "../../steps";
+import { Command } from "../Command";
+
+export class FilterDescriptionCommand extends Command {
+
+ private _openApiTreeProvider: OpenApiTreeProvider;
+
+ constructor(openApiTreeProvider: OpenApiTreeProvider) {
+ super();
+ this._openApiTreeProvider = openApiTreeProvider;
+ }
+
+ public getName(): string {
+ return `${treeViewId}.filterDescription`;
+ }
+
+ public async execute(): Promise {
+ await filterSteps(this._openApiTreeProvider.filter,
+ x => this._openApiTreeProvider.filter = x);
+ }
+
+}
diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-view/openDocumentationPageCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-view/openDocumentationPageCommand.ts
new file mode 100644
index 0000000000..b303d853fc
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/open-api-tree-view/openDocumentationPageCommand.ts
@@ -0,0 +1,17 @@
+import * as vscode from "vscode";
+
+import { treeViewId } from "../../constants";
+import { OpenApiTreeNode } from "../../openApiTreeProvider";
+import { Command } from "../Command";
+
+export class OpenDocumentationPageCommand extends Command {
+
+ public getName(): string {
+ return `${treeViewId}.openDocumentationPage`;
+ }
+
+ public async execute(node: OpenApiTreeNode): Promise {
+ node.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(node.documentationUrl));
+ }
+
+}
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-view/removeAllFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-view/removeAllFromSelectedEndpointsCommand.ts
new file mode 100644
index 0000000000..5eb11da830
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/open-api-tree-view/removeAllFromSelectedEndpointsCommand.ts
@@ -0,0 +1,20 @@
+import { treeViewId } from "../../constants";
+import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
+import { Command } from "../Command";
+
+export class RemoveAllFromSelectedEndpointsCommand extends Command {
+ private _openApiTreeProvider: OpenApiTreeProvider;
+
+ constructor(openApiTreeProvider: OpenApiTreeProvider) {
+ super();
+ this._openApiTreeProvider = openApiTreeProvider;
+ }
+
+ public getName(): string {
+ return `${treeViewId}.removeAllFromSelectedEndpoints`;
+ }
+
+ public async execute(openApiTreeNode: OpenApiTreeNode): Promise {
+ this._openApiTreeProvider.select(openApiTreeNode, false, true);
+ }
+}
diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-view/removeFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-view/removeFromSelectedEndpointsCommand.ts
new file mode 100644
index 0000000000..868d6d6e34
--- /dev/null
+++ b/vscode/microsoft-kiota/src/commands/open-api-tree-view/removeFromSelectedEndpointsCommand.ts
@@ -0,0 +1,20 @@
+import { treeViewId } from "../../constants";
+import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
+import { Command } from "../Command";
+
+export class RemoveFromSelectedEndpointsCommand extends Command {
+ private _openApiTreeProvider: OpenApiTreeProvider;
+
+ constructor(openApiTreeProvider: OpenApiTreeProvider) {
+ super();
+ this._openApiTreeProvider = openApiTreeProvider;
+ }
+
+ public getName(): string {
+ return `${treeViewId}.removeFromSelectedEndpoints`;
+ }
+
+ public async execute(openApiTreeNode: OpenApiTreeNode): Promise {
+ this._openApiTreeProvider.select(openApiTreeNode, false, false);
+ }
+}
diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts
index fe14699388..0ea6a62168 100644
--- a/vscode/microsoft-kiota/src/extension.ts
+++ b/vscode/microsoft-kiota/src/extension.ts
@@ -6,6 +6,13 @@ import * as path from 'path';
import * as vscode from "vscode";
import { CodeLensProvider } from "./codelensProvider";
+import { MigrateFromLockFileCommand } from './commands/migrateFromLockFileCommand';
+import { AddAllToSelectedEndpointsCommand } from './commands/open-api-tree-view/addAllToSelectedEndpointsCommand';
+import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-view/addToSelectedEndpointsCommand';
+import { FilterDescriptionCommand } from './commands/open-api-tree-view/filterDescriptionCommand';
+import { OpenDocumentationPageCommand } from './commands/open-api-tree-view/openDocumentationPageCommand';
+import { RemoveAllFromSelectedEndpointsCommand } from './commands/open-api-tree-view/removeAllFromSelectedEndpointsCommand';
+import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-view/removeFromSelectedEndpointsCommand';
import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants";
import { DependenciesViewProvider } from "./dependenciesViewProvider";
import { GenerationType, KiotaGenerationLanguage, KiotaPluginType } from "./enums";
@@ -25,15 +32,15 @@ import {
import { checkForLockFileAndPrompt } from "./migrateFromLockFile";
import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider";
import { searchDescription } from "./searchDescription";
-import { GenerateState, filterSteps, generateSteps, searchSteps } from "./steps";
+import { GenerateState, generateSteps, searchSteps } from "./steps";
import { updateClients } from "./updateClients";
import {
getSanitizedString, getWorkspaceJsonDirectory, getWorkspaceJsonPath,
- handleMigration,
isClientType, isPluginType, parseGenerationLanguage,
parseGenerationType, parsePluginType, updateTreeViewIcons
} from "./util";
import { IntegrationParams, isDeeplinkEnabled, transformToGenerationConfig, validateDeepLinkQueryParams } from './utilities/deep-linking';
+import { confirmOverride } from './utilities/regeneration';
import { loadTreeView } from "./workspaceTreeProvider";
let kiotaStatusBarItem: vscode.StatusBarItem;
@@ -60,6 +67,15 @@ export async function activate(
context.extensionUri
);
const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey);
+
+ const migrateFromLockFileCommand = new MigrateFromLockFileCommand(context);
+ const addAllToSelectedEndpointsCommand = new AddAllToSelectedEndpointsCommand(openApiTreeProvider);
+ const addToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider);
+ const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider);
+ const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider);
+ const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider);
+ const openDocumentationPageCommand = new OpenDocumentationPageCommand();
+
await loadTreeView(context);
await checkForLockFileAndPrompt(context);
let codeLensProvider = new CodeLensProvider();
@@ -112,26 +128,12 @@ export async function activate(
dependenciesInfoProvider
),
vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider),
- registerCommandWithTelemetry(reporter,
- `${treeViewId}.openDocumentationPage`,
- (x: OpenApiTreeNode) => x.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(x.documentationUrl))
- ),
- registerCommandWithTelemetry(reporter,
- `${treeViewId}.addToSelectedEndpoints`,
- (x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, false)
- ),
- registerCommandWithTelemetry(reporter,
- `${treeViewId}.addAllToSelectedEndpoints`,
- (x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, true)
- ),
- registerCommandWithTelemetry(reporter,
- `${treeViewId}.removeFromSelectedEndpoints`,
- (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, false)
- ),
- registerCommandWithTelemetry(reporter,
- `${treeViewId}.removeAllFromSelectedEndpoints`,
- (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true)
- ),
+ registerCommandWithTelemetry(reporter, openDocumentationPageCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await openDocumentationPageCommand.execute(openApiTreeNode)),
+ registerCommandWithTelemetry(reporter, addToSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await addToSelectedEndpointsCommand.execute(openApiTreeNode)),
+ registerCommandWithTelemetry(reporter, addAllToSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await addAllToSelectedEndpointsCommand.execute(openApiTreeNode)),
+ registerCommandWithTelemetry(reporter, removeFromSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await removeFromSelectedEndpointsCommand.execute(openApiTreeNode)),
+ registerCommandWithTelemetry(reporter, removeAllFromSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)),
+
registerCommandWithTelemetry(reporter,
`${treeViewId}.generateClient`,
async () => {
@@ -300,11 +302,8 @@ export async function activate(
}
}
),
- registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`,
- async () => {
- await filterSteps(openApiTreeProvider.filter, x => openApiTreeProvider.filter = x);
- }
- ),
+ registerCommandWithTelemetry(reporter, filterDescriptionCommand.getName(), async () => await filterDescriptionCommand.execute()),
+
registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => {
clientOrPluginKey = clientKey;
clientOrPluginObject = clientObject;
@@ -314,6 +313,11 @@ export async function activate(
await updateTreeViewIcons(treeViewId, false, true);
}),
registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => {
+ const regenerate = await confirmOverride();
+ if (!regenerate) {
+ return;
+ }
+
if (!clientOrPluginKey || clientOrPluginKey === '') {
clientOrPluginKey = config.clientClassName || config.pluginName || '';
}
@@ -339,6 +343,11 @@ export async function activate(
}
}),
registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => {
+ const regenerate = await confirmOverride();
+ if (!regenerate) {
+ return;
+ }
+
const settings = getExtensionSettings(extensionId);
const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE));
if (workspaceJson && workspaceJson.isDirty) {
@@ -355,16 +364,7 @@ export async function activate(
await regeneratePlugin(clientKey, clientObject, settings);
}
}),
- registerCommandWithTelemetry(reporter, `${extensionId}.migrateFromLockFile`, async (uri: vscode.Uri) => {
- const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
-
- if (!workspaceFolder) {
- vscode.window.showErrorMessage(vscode.l10n.t("Could not determine the workspace folder."));
- return;
- }
-
- await handleMigration(context, workspaceFolder);
- })
+ registerCommandWithTelemetry(reporter, migrateFromLockFileCommand.getName(), async (uri: vscode.Uri) => await migrateFromLockFileCommand.execute(uri)),
);
async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise {
@@ -449,7 +449,7 @@ export async function activate(
if (!isSuccess) {
await exportLogsAndShowErrors(result);
}
- const isttkIntegration = deepLinkParams.source && deepLinkParams.source.toLowerCase() === 'ttk'? true : false;
+ const isttkIntegration = deepLinkParams.source && deepLinkParams.source.toLowerCase() === 'ttk';
if (!isttkIntegration) {
void vscode.window.showInformationMessage(vscode.l10n.t('Plugin generated successfully.'));
}
diff --git a/vscode/microsoft-kiota/src/generateClient.ts b/vscode/microsoft-kiota/src/generateClient.ts
index ea0be0813b..5638d3b8b9 100644
--- a/vscode/microsoft-kiota/src/generateClient.ts
+++ b/vscode/microsoft-kiota/src/generateClient.ts
@@ -24,35 +24,31 @@ export function generateClient(context: vscode.ExtensionContext,
operation: ConsumerOperation,
workingDirectory: string = getWorkspaceJsonDirectory()
): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType1(
- "Generate"
- );
- return await connection.sendRequest(
- request,
- {
- cleanOutput: cleanOutput,
- clearCache: clearCache,
- clientClassName: clientClassName,
- clientNamespaceName: clientNamespaceName,
- deserializers: deserializers,
- disabledValidationRules: disableValidationRules,
- excludeBackwardCompatible: excludeBackwardCompatible,
- excludePatterns: excludeFilters,
- includeAdditionalData: includeAdditionalData,
- includePatterns: includeFilters,
- language: language,
- openAPIFilePath: descriptionPath,
- outputPath: output,
- serializers: serializers,
- structuredMimeTypes: structuredMimeTypes,
- usesBackingStore: usesBackingStore,
- operation: operation
- } as GenerationConfiguration,
- );
- }, workingDirectory);
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType1(
+ "Generate"
+ );
+ return await connection.sendRequest(
+ request,
+ {
+ cleanOutput: cleanOutput,
+ clearCache: clearCache,
+ clientClassName: clientClassName,
+ clientNamespaceName: clientNamespaceName,
+ deserializers: deserializers,
+ disabledValidationRules: disableValidationRules,
+ excludeBackwardCompatible: excludeBackwardCompatible,
+ excludePatterns: excludeFilters,
+ includeAdditionalData: includeAdditionalData,
+ includePatterns: includeFilters,
+ language: language,
+ openAPIFilePath: descriptionPath,
+ outputPath: output,
+ serializers: serializers,
+ structuredMimeTypes: structuredMimeTypes,
+ usesBackingStore: usesBackingStore,
+ operation: operation
+ } as GenerationConfiguration,
+ );
+ }, workingDirectory);
};
diff --git a/vscode/microsoft-kiota/src/generatePlugin.ts b/vscode/microsoft-kiota/src/generatePlugin.ts
index 134515ae55..caa57d2bce 100644
--- a/vscode/microsoft-kiota/src/generatePlugin.ts
+++ b/vscode/microsoft-kiota/src/generatePlugin.ts
@@ -16,28 +16,24 @@ export function generatePlugin(context: vscode.ExtensionContext,
disableValidationRules: string[],
operation: ConsumerOperation,
workingDirectory: string = getWorkspaceJsonDirectory()): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType1(
- "GeneratePlugin"
- );
- return await connection.sendRequest(
- request,
- {
- pluginTypes: pluginTypes,
- cleanOutput: cleanOutput,
- clearCache: clearCache,
- clientClassName: clientClassName,
- disabledValidationRules: disableValidationRules,
- excludePatterns: excludeFilters,
- includePatterns: includeFilters,
- openAPIFilePath: descriptionPath,
- outputPath: output,
- operation: operation
- } as GenerationConfiguration,
- );
- }, workingDirectory);
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType1(
+ "GeneratePlugin"
+ );
+ return await connection.sendRequest(
+ request,
+ {
+ pluginTypes: pluginTypes,
+ cleanOutput: cleanOutput,
+ clearCache: clearCache,
+ clientClassName: clientClassName,
+ disabledValidationRules: disableValidationRules,
+ excludePatterns: excludeFilters,
+ includePatterns: includeFilters,
+ openAPIFilePath: descriptionPath,
+ outputPath: output,
+ operation: operation
+ } as GenerationConfiguration,
+ );
+ }, workingDirectory);
};
diff --git a/vscode/microsoft-kiota/src/getKiotaVersion.ts b/vscode/microsoft-kiota/src/getKiotaVersion.ts
index 7e6f3c3852..2a09e6bc98 100644
--- a/vscode/microsoft-kiota/src/getKiotaVersion.ts
+++ b/vscode/microsoft-kiota/src/getKiotaVersion.ts
@@ -3,22 +3,18 @@ import * as rpc from "vscode-jsonrpc/node";
import * as vscode from "vscode";
export function getKiotaVersion(context: vscode.ExtensionContext, kiotaOutputChannel: vscode.LogOutputChannel): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType0("GetVersion");
- const result = await connection.sendRequest(request);
- if (result) {
- const version = result.split("+")[0];
- if (version) {
- kiotaOutputChannel.info(`kiota: ${version}`);
- return version;
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType0("GetVersion");
+ const result = await connection.sendRequest(request);
+ if (result) {
+ const version = result.split("+")[0];
+ if (version) {
+ kiotaOutputChannel.info(`kiota: ${version}`);
+ return version;
}
- kiotaOutputChannel.error(`kiota: ${vscode.l10n.t('not found')}`);
- kiotaOutputChannel.show();
- return undefined;
- });
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ }
+ kiotaOutputChannel.error(`kiota: ${vscode.l10n.t('not found')}`);
+ kiotaOutputChannel.show();
+ return undefined;
+ });
};
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/getLanguageInformation.ts b/vscode/microsoft-kiota/src/getLanguageInformation.ts
index 9717f16f5e..eec21808f6 100644
--- a/vscode/microsoft-kiota/src/getLanguageInformation.ts
+++ b/vscode/microsoft-kiota/src/getLanguageInformation.ts
@@ -15,33 +15,25 @@ export async function getLanguageInformation(context: vscode.ExtensionContext):
};
function getLanguageInformationInternal(context: vscode.ExtensionContext): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType0(
- "Info"
- );
- return await connection.sendRequest(
- request,
- );
- });
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType0(
+ "Info"
+ );
+ return await connection.sendRequest(
+ request,
+ );
+ });
};
export function getLanguageInformationForDescription(context: vscode.ExtensionContext, descriptionUrl: string, clearCache: boolean): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType2(
- "InfoForDescription"
- );
- return await connection.sendRequest(
- request,
- descriptionUrl,
- clearCache
- );
- });
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType2(
+ "InfoForDescription"
+ );
+ return await connection.sendRequest(
+ request,
+ descriptionUrl,
+ clearCache
+ );
+ });
};
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts
index 2bb530d143..433b720c00 100644
--- a/vscode/microsoft-kiota/src/kiotaInterop.ts
+++ b/vscode/microsoft-kiota/src/kiotaInterop.ts
@@ -25,7 +25,7 @@ export async function connectToKiota(context: vscode.ExtensionContext, callba
} catch (error) {
const errorMessage = (error as { data?: { message: string } })?.data?.message
|| 'An unknown error occurred';
- throw new Error(errorMessage);
+ vscode.window.showErrorMessage(errorMessage);
} finally {
connection.dispose();
childProcess.kill();
@@ -197,30 +197,30 @@ export function maturityLevelToString(level: MaturityLevel): string {
}
}
export enum DependencyType {
- abstractions,
- serialization,
- authentication,
- http,
- bundle,
- additional,
+ abstractions,
+ serialization,
+ authentication,
+ http,
+ bundle,
+ additional,
}
export function dependencyTypeToString(type: DependencyType): string {
- switch (type) {
- case DependencyType.abstractions:
- return "abstractions";
- case DependencyType.serialization:
- return "serialization";
- case DependencyType.authentication:
- return "authentication";
- case DependencyType.http:
- return "http";
- case DependencyType.bundle:
- return "bundle";
- case DependencyType.additional:
- return "additional";
- default:
- throw new Error("unknown type");
- }
+ switch (type) {
+ case DependencyType.abstractions:
+ return "abstractions";
+ case DependencyType.serialization:
+ return "serialization";
+ case DependencyType.authentication:
+ return "authentication";
+ case DependencyType.http:
+ return "http";
+ case DependencyType.bundle:
+ return "bundle";
+ case DependencyType.additional:
+ return "additional";
+ default:
+ throw new Error("unknown type");
+ }
}
export interface ConfigurationFile {
version: string;
diff --git a/vscode/microsoft-kiota/src/migrateFromLockFile.ts b/vscode/microsoft-kiota/src/migrateFromLockFile.ts
index c1c1d3acdf..893412f557 100644
--- a/vscode/microsoft-kiota/src/migrateFromLockFile.ts
+++ b/vscode/microsoft-kiota/src/migrateFromLockFile.ts
@@ -5,20 +5,16 @@ import { KIOTA_LOCK_FILE } from "./constants";
import { getWorkspaceJsonPath, handleMigration } from "./util";
export function migrateFromLockFile(context: vscode.ExtensionContext, lockFileDirectory: string): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType1(
- "MigrateFromLockFile"
- );
- const result = await connection.sendRequest(
- request,
- lockFileDirectory
- );
- return result;
- });
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType1(
+ "MigrateFromLockFile"
+ );
+ const result = await connection.sendRequest(
+ request,
+ lockFileDirectory
+ );
+ return result;
+ });
};
export async function checkForLockFileAndPrompt(context: vscode.ExtensionContext) {
diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts
index bf25c636d0..d8cb256d63 100644
--- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts
+++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts
@@ -292,7 +292,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider x !== '').map(x => x.trim().toLowerCase()).sort();
+ this.tokenizedFilter = filterText.length === 0 ? [] : filterText.split(' ').filter(x => x !== '').map(x => x.trim().toLowerCase()).sort((a, b) => a.localeCompare(b));
this.refreshView();
}
public get filter(): string {
@@ -320,40 +320,36 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider {
- const request = new rpc.RequestType('Show');
- return await connection.sendRequest(request, {
- includeFilters: this.includeFilters,
- excludeFilters: this.excludeFilters,
- descriptionPath: this.descriptionUrl,
- clearCache
- });
+ const result = await connectToKiota(this.context, async (connection) => {
+ const request = new rpc.RequestType('Show');
+ return await connection.sendRequest(request, {
+ includeFilters: this.includeFilters,
+ excludeFilters: this.excludeFilters,
+ descriptionPath: this.descriptionUrl,
+ clearCache
});
- if (result) {
- this.apiTitle = result.apiTitle;
- if (result.rootNode) {
- if (this.includeFilters.length === 0) {
- this.setAllSelected(result.rootNode, false);
- }
- this.rawRootNode = result.rootNode;
- if (clientNameOrPluginName) {
- this.rawRootNode = createKiotaOpenApiNode(
- clientNameOrPluginName,
- '/',
- [this.rawRootNode],
- false,
- false,
- undefined,
- clientNameOrPluginName
- );
- }
- await updateTreeViewIcons(treeViewId, true, false);
+ });
+ if (result) {
+ this.apiTitle = result.apiTitle;
+ if (result.rootNode) {
+ if (this.includeFilters.length === 0) {
+ this.setAllSelected(result.rootNode, false);
+ }
+ this.rawRootNode = result.rootNode;
+ if (clientNameOrPluginName) {
+ this.rawRootNode = createKiotaOpenApiNode(
+ clientNameOrPluginName,
+ '/',
+ [this.rawRootNode],
+ false,
+ false,
+ undefined,
+ clientNameOrPluginName
+ );
}
- void vscode.window.showInformationMessage(vscode.l10n.t('You can now select the required endpoints from {0}', this.apiTitle!));
+ await updateTreeViewIcons(treeViewId, true, false);
}
- } catch (err) {
- vscode.window.showErrorMessage((err as Error)?.message || 'An unknown error occurred');
+ void vscode.window.showInformationMessage(vscode.l10n.t('You can now select the required endpoints from {0}', this.apiTitle!));
}
}
getCollapsedState(node: KiotaOpenApiNode): vscode.TreeItemCollapsibleState {
diff --git a/vscode/microsoft-kiota/src/searchDescription.ts b/vscode/microsoft-kiota/src/searchDescription.ts
index 6fe76032ba..e69d9afc6a 100644
--- a/vscode/microsoft-kiota/src/searchDescription.ts
+++ b/vscode/microsoft-kiota/src/searchDescription.ts
@@ -3,22 +3,18 @@ import * as rpc from "vscode-jsonrpc/node";
import * as vscode from "vscode";
export function searchDescription(context: vscode.ExtensionContext, searchTerm: string, clearCache: boolean): Promise | undefined> {
- try {
- return connectToKiota>(context, async (connection) => {
- const request = new rpc.RequestType2(
- "Search"
- );
- const result = await connection.sendRequest(
- request,
- searchTerm,
- clearCache,
- );
- if (result) {
- return result.results;
- }
- return undefined;
- });
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota>(context, async (connection) => {
+ const request = new rpc.RequestType2(
+ "Search"
+ );
+ const result = await connection.sendRequest(
+ request,
+ searchTerm,
+ clearCache,
+ );
+ if (result) {
+ return result.results;
+ }
+ return undefined;
+ });
};
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/updateClients.ts b/vscode/microsoft-kiota/src/updateClients.ts
index d47f158f1f..6d34476f1b 100644
--- a/vscode/microsoft-kiota/src/updateClients.ts
+++ b/vscode/microsoft-kiota/src/updateClients.ts
@@ -3,20 +3,16 @@ import * as rpc from "vscode-jsonrpc/node";
import * as vscode from "vscode";
export function updateClients(context: vscode.ExtensionContext, cleanOutput: boolean, clearCache: boolean): Promise {
- try {
- return connectToKiota(context, async (connection) => {
- const request = new rpc.RequestType3(
- "Update"
- );
- const result = await connection.sendRequest(
- request,
- vscode.workspace.workspaceFolders![0].uri.fsPath,
- cleanOutput,
- clearCache,
- );
- return result;
- });
- } catch (error) {
- return Promise.resolve(undefined);
- }
+ return connectToKiota(context, async (connection) => {
+ const request = new rpc.RequestType3(
+ "Update"
+ );
+ const result = await connection.sendRequest(
+ request,
+ vscode.workspace.workspaceFolders![0].uri.fsPath,
+ cleanOutput,
+ clearCache,
+ );
+ return result;
+ });
};
\ No newline at end of file
diff --git a/vscode/microsoft-kiota/src/utilities/regeneration.ts b/vscode/microsoft-kiota/src/utilities/regeneration.ts
new file mode 100644
index 0000000000..5a8f8a775d
--- /dev/null
+++ b/vscode/microsoft-kiota/src/utilities/regeneration.ts
@@ -0,0 +1,12 @@
+import * as vscode from "vscode";
+
+export async function confirmOverride(): Promise {
+ const yesAnswer = vscode.l10n.t("Yes, override it");
+ const confirmation = await vscode.window
+ .showWarningMessage(
+ vscode.l10n.t("When regenerating, all changes made manually to the generated files will be overridden."),
+ yesAnswer,
+ vscode.l10n.t("Cancel")
+ );
+ return confirmation === yesAnswer;
+}
\ No newline at end of file