From 08c525410bf36ed235e969c3ec7aa7ac0bd78fe0 Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Mon, 1 Apr 2024 13:37:15 +0100 Subject: [PATCH 1/7] [TS] Fix 4426 --- .github/workflows/integration-tests.yml | 3 +- it/typescript/package.json | 4 +- it/typescript/src/app/app.ts | 4 +- it/typescript/src/app/client/apiClient.ts | 56 +++++++++++++++++++ it/typescript/src/app/client/kiota-lock.json | 32 +++++++++++ it/typescript/src/app/client/models/index.ts | 12 ++++ it/typescript/src/app/client/play/index.ts | 42 ++++++++++++++ .../Refiners/TypeScriptRefiner.cs | 24 +++++++- .../Writers/TypeScript/CodeConstantWriter.cs | 9 ++- .../EnumHandling.yaml | 29 ++++++++++ .../GenerateSample.cs | 22 ++++++++ .../Kiota.Builder.IntegrationTests.csproj | 3 + 12 files changed, 233 insertions(+), 7 deletions(-) create mode 100644 it/typescript/src/app/client/apiClient.ts create mode 100644 it/typescript/src/app/client/kiota-lock.json create mode 100644 it/typescript/src/app/client/models/index.ts create mode 100644 it/typescript/src/app/client/play/index.ts create mode 100644 tests/Kiota.Builder.IntegrationTests/EnumHandling.yaml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 8e1fc56376..af6046f4b4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -45,6 +45,7 @@ jobs: - python description: - "./tests/Kiota.Builder.IntegrationTests/InheritingErrors.yaml" + - "./tests/Kiota.Builder.IntegrationTests/EnumHandling.yaml" - "./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml" - "./tests/Kiota.Builder.IntegrationTests/ToDoApi.yaml" - "./tests/Kiota.Builder.IntegrationTests/GeneratesUritemplateHints.yaml" @@ -59,7 +60,7 @@ jobs: - "apisguru::docusign.net" - "apisguru::github.com:api.github.com" - "apisguru::apis.guru" - + steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 diff --git a/it/typescript/package.json b/it/typescript/package.json index 255849aaba..2369ac4f71 100644 --- a/it/typescript/package.json +++ b/it/typescript/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "license": "MIT", "scripts": { - "build": "node ./build/esbuild.js --dev", + "build": "tsc -noEmit && node ./build/esbuild.js --dev", "build:meta": "node ./build/esbuild.js --dev --meta", "build:meta:prod": "node ./build/esbuild.js --meta", "build:prod": "node ./build/esbuild.js", @@ -41,4 +41,4 @@ "express": "^4.19.2", "node-fetch": "^2.7.0" } -} +} \ No newline at end of file diff --git a/it/typescript/src/app/app.ts b/it/typescript/src/app/app.ts index d724061b91..919dcfe915 100644 --- a/it/typescript/src/app/app.ts +++ b/it/typescript/src/app/app.ts @@ -3,7 +3,7 @@ import { Logger } from './common/logger'; import { DeviceCodeCredential } from '@azure/identity'; import { FetchRequestAdapter } from '@microsoft/kiota-http-fetchlibrary'; import { AzureIdentityAuthenticationProvider } from '@microsoft/kiota-authentication-azure'; -import { type ApiClient } from './client/apiClient'; +import { createApiClient } from './client/apiClient'; export class App { static run(): App { @@ -19,7 +19,7 @@ export class App { }); const authProvider = new AzureIdentityAuthenticationProvider(cred, ['Mail.Read']); const requestAdapter = new FetchRequestAdapter(authProvider); - const client = new ApiClient(requestAdapter); + const client = createApiClient(requestAdapter); Logger.log(`${client}`); return app; } diff --git a/it/typescript/src/app/client/apiClient.ts b/it/typescript/src/app/client/apiClient.ts new file mode 100644 index 0000000000..315953cf09 --- /dev/null +++ b/it/typescript/src/app/client/apiClient.ts @@ -0,0 +1,56 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { PlayRequestBuilderRequestsMetadata, type PlayRequestBuilder } from './play/'; +// @ts-ignore +import { apiClientProxifier, registerDefaultDeserializer, registerDefaultSerializer, type BaseRequestBuilder, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type RequestAdapter } from '@microsoft/kiota-abstractions'; +// @ts-ignore +import { FormParseNodeFactory, FormSerializationWriterFactory } from '@microsoft/kiota-serialization-form'; +// @ts-ignore +import { JsonParseNodeFactory, JsonSerializationWriterFactory } from '@microsoft/kiota-serialization-json'; +// @ts-ignore +import { MultipartSerializationWriterFactory } from '@microsoft/kiota-serialization-multipart'; +// @ts-ignore +import { TextParseNodeFactory, TextSerializationWriterFactory } from '@microsoft/kiota-serialization-text'; + +/** + * The main entry point of the SDK, exposes the configuration and the fluent API. + */ +export interface ApiClient extends BaseRequestBuilder { + /** + * The play property + */ + get play(): PlayRequestBuilder; +} +/** + * Instantiates a new {@link ApiClient} and sets the default values. + * @param requestAdapter The request adapter to use to execute the requests. + */ +export function createApiClient(requestAdapter: RequestAdapter) { + registerDefaultSerializer(JsonSerializationWriterFactory); + registerDefaultSerializer(TextSerializationWriterFactory); + registerDefaultSerializer(FormSerializationWriterFactory); + registerDefaultSerializer(MultipartSerializationWriterFactory); + registerDefaultDeserializer(JsonParseNodeFactory); + registerDefaultDeserializer(TextParseNodeFactory); + registerDefaultDeserializer(FormParseNodeFactory); + const pathParameters: Record = { + "baseurl": requestAdapter.baseUrl, + }; + return apiClientProxifier(requestAdapter, pathParameters, ApiClientNavigationMetadata, undefined); +} +/** + * Uri template for the request builder. + */ +export const ApiClientUriTemplate = "{+baseurl}"; +/** + * Metadata for all the navigation properties in the request builder. + */ +export const ApiClientNavigationMetadata: Record, NavigationMetadata> = { + play: { + requestsMetadata: PlayRequestBuilderRequestsMetadata, + }, +}; +/* tslint:enable */ +/* eslint-enable */ diff --git a/it/typescript/src/app/client/kiota-lock.json b/it/typescript/src/app/client/kiota-lock.json new file mode 100644 index 0000000000..cb884c395c --- /dev/null +++ b/it/typescript/src/app/client/kiota-lock.json @@ -0,0 +1,32 @@ +{ + "descriptionHash": "20EF99AD604AC7A78DCA5739B05E981E373C6EE21B6D1228B4236028E243FF16760BA2A652767B6D19080C0B4AFE03EA43AF77FCB2BEAB51087C1350A0F6647E", + "descriptionLocation": "../../../../openapi.yaml", + "lockFileVersion": "1.0.0", + "kiotaVersion": "1.13.0", + "clientClassName": "ApiClient", + "clientNamespaceName": "app.client", + "language": "TypeScript", + "usesBackingStore": false, + "excludeBackwardCompatible": true, + "includeAdditionalData": true, + "serializers": [ + "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory", + "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory", + "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory", + "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory" + ], + "deserializers": [ + "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory", + "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory", + "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory" + ], + "structuredMimeTypes": [ + "application/json", + "text/plain;q=0.9", + "application/x-www-form-urlencoded;q=0.2", + "multipart/form-data;q=0.1" + ], + "includePatterns": [], + "excludePatterns": [], + "disabledValidationRules": [] +} \ No newline at end of file diff --git a/it/typescript/src/app/client/models/index.ts b/it/typescript/src/app/client/models/index.ts new file mode 100644 index 0000000000..a88aebfdec --- /dev/null +++ b/it/typescript/src/app/client/models/index.ts @@ -0,0 +1,12 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota + +export type MoveType = (typeof MoveTypeObject)[keyof typeof MoveTypeObject]; +export const MoveTypeObject = { + ROCK: "ROCK", + PAPER: "PAPER", + SCISSORS: "SCISSORS", +} as const; +/* tslint:enable */ +/* eslint-enable */ diff --git a/it/typescript/src/app/client/play/index.ts b/it/typescript/src/app/client/play/index.ts new file mode 100644 index 0000000000..5692169f43 --- /dev/null +++ b/it/typescript/src/app/client/play/index.ts @@ -0,0 +1,42 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { MoveType, MoveTypeObject } from '../models/'; +// @ts-ignore +import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; + +/** + * Builds and executes requests for operations under /play + */ +export interface PlayRequestBuilder extends BaseRequestBuilder { + /** + * Play a move + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {Promise} + */ + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + /** + * Play a move + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {RequestInformation} + */ + toGetRequestInformation(requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; +} +/** + * Uri template for the request builder. + */ +export const PlayRequestBuilderUriTemplate = "{+baseurl}/play"; +/** + * Metadata for all the requests in the request builder. + */ +export const PlayRequestBuilderRequestsMetadata: RequestsMetadata = { + get: { + uriTemplate: PlayRequestBuilderUriTemplate, + responseBodyContentType: "application/json", + adapterMethodName: "sendEnum", + enumObject: MoveTypeObject, + }, +}; +/* tslint:enable */ +/* eslint-enable */ diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index 7a3d3aa436..c71a061a82 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -6,6 +6,7 @@ using Kiota.Builder.CodeDOM; using Kiota.Builder.Configuration; using Kiota.Builder.Extensions; +using Microsoft.Kiota.Http.HttpClientLibrary; namespace Kiota.Builder.Refiners; public class TypeScriptRefiner : CommonLanguageRefiner, ILanguageRefiner @@ -1103,9 +1104,30 @@ protected static void AddEnumObject(CodeElement currentElement) } CrawlTree(currentElement, AddEnumObject); } + protected static IEnumerable selectEnums(IEnumerable props) + { + return props.Select(static x => x.Type).OfType().Select(static x => x.TypeDefinition).OfType(); + } protected static void AddEnumObjectUsings(CodeElement currentElement) { + if (currentElement is CodeProperty codeProperty && codeProperty.Kind is CodePropertyKind.RequestBuilder && codeProperty.Type is CodeType codeType && codeType.TypeDefinition is CodeClass codeClass) + { + foreach (var propertyMethod in codeClass.Methods) + { + if (propertyMethod.ReturnType is CodeType ct && ct.TypeDefinition is CodeEnum codeEnum) + { + codeClass.AddUsing(new CodeUsing + { + Name = codeEnum.Name, + Declaration = new CodeType + { + TypeDefinition = codeEnum.CodeEnumObject + } + }); + } + } + } if (currentElement is CodeFunction codeFunction && codeFunction.OriginalLocalMethod.IsOfKind(CodeMethodKind.Deserializer, CodeMethodKind.Serializer)) { foreach (var propertyEnum in codeFunction.OriginalMethodParentClass.Properties.Select(static x => x.Type).OfType().Select(static x => x.TypeDefinition).OfType()) @@ -1120,7 +1142,7 @@ protected static void AddEnumObjectUsings(CodeElement currentElement) }); } } - CrawlTree(currentElement, AddEnumObjectUsings); + CrawlTree(currentElement!, AddEnumObjectUsings); } private static void ProcessModelClassProperties(CodeClass modelClass, CodeInterface modelInterface, IEnumerable properties, Func interfaceNamingCallback) diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs index 70467c719c..c78bb77f6d 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs @@ -119,7 +119,14 @@ private void WriteRequestsMetadataConstant(CodeConstant codeElement, LanguageWri } writer.WriteLine($"adapterMethodName: \"{GetSendRequestMethodName(isVoid, isStream, executorMethod.ReturnType.IsCollection, isPrimitive, isEnum)}\","); if (isEnum) - writer.WriteLine($"enumObject: {executorMethod.ReturnType.Name.ToFirstCharacterUpperCase()},"); + { + string enumObjectName = string.Empty; + if (executorMethod.ReturnType is CodeType ct && ct.TypeDefinition is CodeEnum ce) + { + enumObjectName = ce.CodeEnumObject!.Name; + } + writer.WriteLine($"enumObject: {enumObjectName!.ToFirstCharacterUpperCase()},"); + } else if (!isVoid) writer.WriteLine($"responseBodyFactory: {GetTypeFactory(isVoid, isStream, executorMethod, writer)},"); var sanitizedRequestBodyContentType = executorMethod.RequestBodyContentType.SanitizeDoubleQuote(); diff --git a/tests/Kiota.Builder.IntegrationTests/EnumHandling.yaml b/tests/Kiota.Builder.IntegrationTests/EnumHandling.yaml new file mode 100644 index 0000000000..43a6cb0eb2 --- /dev/null +++ b/tests/Kiota.Builder.IntegrationTests/EnumHandling.yaml @@ -0,0 +1,29 @@ +openapi: 3.0.3 +info: + title: Test + version: 3.0.x + description: Testing enum handling. + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0 +paths: + "/play": + get: + responses: + "200": + content: + application/json: + schema: + "$ref": "#/components/schemas/MoveType" + description: A move + description: "Play a move" +components: + schemas: + MoveType: + description: "" + enum: + - ROCK + - PAPER + - SCISSORS + type: string + example: ROCK diff --git a/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs b/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs index 7fba8971a5..e501197158 100644 --- a/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs +++ b/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs @@ -116,6 +116,28 @@ public async Task GeneratesErrorsInliningParents(GenerationLanguage language) }; await new KiotaBuilder(logger, configuration, _httpClient).GenerateClientAsync(new()); } + [InlineData(GenerationLanguage.CSharp)] + [InlineData(GenerationLanguage.Java)] + [InlineData(GenerationLanguage.Go)] + [InlineData(GenerationLanguage.Ruby)] + [InlineData(GenerationLanguage.Python)] + [InlineData(GenerationLanguage.TypeScript)] + [InlineData(GenerationLanguage.PHP)] + [Theory] + public async Task GeneratesCorrectEnums(GenerationLanguage language) + { + var logger = LoggerFactory.Create(builder => + { + }).CreateLogger(); + + var configuration = new GenerationConfiguration + { + Language = language, + OpenAPIFilePath = GetAbsolutePath("EnumHandling.yaml"), + OutputPath = $".\\Generated\\EnumHandling\\{language}", + }; + await new KiotaBuilder(logger, configuration, _httpClient).GenerateClientAsync(new()); + } [InlineData(GenerationLanguage.Java)] [Theory] public async Task GeneratesIdiomaticChildrenNames(GenerationLanguage language) diff --git a/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj b/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj index 5fa8150c95..490f14c266 100644 --- a/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj +++ b/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj @@ -49,6 +49,9 @@ PreserveNewest + + PreserveNewest + \ No newline at end of file From bb1c8f9e5bb7563e01b19583f93799ec4535c6aa Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Mon, 1 Apr 2024 13:37:55 +0100 Subject: [PATCH 2/7] test in CI --- .github/workflows/integration-tests.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index af6046f4b4..e85725a841 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,10 +1,11 @@ name: integration-tests on: - workflow_dispatch: push: - branches: [main] - pull_request: + # workflow_dispatch: + # push: + # branches: [main] + # pull_request: concurrency: # Only run once for latest commit per ref and cancel other (previous) runs. From 0a5695a3c27d13756fd3ceb81b91f7a2ace2385a Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Mon, 1 Apr 2024 13:46:10 +0100 Subject: [PATCH 3/7] restore ci --- .github/workflows/integration-tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index e85725a841..af6046f4b4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,11 +1,10 @@ name: integration-tests on: + workflow_dispatch: push: - # workflow_dispatch: - # push: - # branches: [main] - # pull_request: + branches: [main] + pull_request: concurrency: # Only run once for latest commit per ref and cancel other (previous) runs. From 9b9bf49d6fffd815ee724797e2304b3b10666c1a Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Mon, 1 Apr 2024 13:49:02 +0100 Subject: [PATCH 4/7] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef449d8dd..24efe3bdb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ 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) +- Fixed TypeScript generation bug when returning enums from endpoints. [#4426](https://github.com/microsoft/kiota/issues/4426) ### Changed From 4023461ee977e6e7aefc4031ceaa7600ad1df26d Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Mon, 1 Apr 2024 13:50:25 +0100 Subject: [PATCH 5/7] cleanup --- it/typescript/src/app/client/apiClient.ts | 56 -------------------- it/typescript/src/app/client/kiota-lock.json | 32 ----------- it/typescript/src/app/client/models/index.ts | 12 ----- it/typescript/src/app/client/play/index.ts | 42 --------------- 4 files changed, 142 deletions(-) delete mode 100644 it/typescript/src/app/client/apiClient.ts delete mode 100644 it/typescript/src/app/client/kiota-lock.json delete mode 100644 it/typescript/src/app/client/models/index.ts delete mode 100644 it/typescript/src/app/client/play/index.ts diff --git a/it/typescript/src/app/client/apiClient.ts b/it/typescript/src/app/client/apiClient.ts deleted file mode 100644 index 315953cf09..0000000000 --- a/it/typescript/src/app/client/apiClient.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// Generated by Microsoft Kiota -// @ts-ignore -import { PlayRequestBuilderRequestsMetadata, type PlayRequestBuilder } from './play/'; -// @ts-ignore -import { apiClientProxifier, registerDefaultDeserializer, registerDefaultSerializer, type BaseRequestBuilder, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type RequestAdapter } from '@microsoft/kiota-abstractions'; -// @ts-ignore -import { FormParseNodeFactory, FormSerializationWriterFactory } from '@microsoft/kiota-serialization-form'; -// @ts-ignore -import { JsonParseNodeFactory, JsonSerializationWriterFactory } from '@microsoft/kiota-serialization-json'; -// @ts-ignore -import { MultipartSerializationWriterFactory } from '@microsoft/kiota-serialization-multipart'; -// @ts-ignore -import { TextParseNodeFactory, TextSerializationWriterFactory } from '@microsoft/kiota-serialization-text'; - -/** - * The main entry point of the SDK, exposes the configuration and the fluent API. - */ -export interface ApiClient extends BaseRequestBuilder { - /** - * The play property - */ - get play(): PlayRequestBuilder; -} -/** - * Instantiates a new {@link ApiClient} and sets the default values. - * @param requestAdapter The request adapter to use to execute the requests. - */ -export function createApiClient(requestAdapter: RequestAdapter) { - registerDefaultSerializer(JsonSerializationWriterFactory); - registerDefaultSerializer(TextSerializationWriterFactory); - registerDefaultSerializer(FormSerializationWriterFactory); - registerDefaultSerializer(MultipartSerializationWriterFactory); - registerDefaultDeserializer(JsonParseNodeFactory); - registerDefaultDeserializer(TextParseNodeFactory); - registerDefaultDeserializer(FormParseNodeFactory); - const pathParameters: Record = { - "baseurl": requestAdapter.baseUrl, - }; - return apiClientProxifier(requestAdapter, pathParameters, ApiClientNavigationMetadata, undefined); -} -/** - * Uri template for the request builder. - */ -export const ApiClientUriTemplate = "{+baseurl}"; -/** - * Metadata for all the navigation properties in the request builder. - */ -export const ApiClientNavigationMetadata: Record, NavigationMetadata> = { - play: { - requestsMetadata: PlayRequestBuilderRequestsMetadata, - }, -}; -/* tslint:enable */ -/* eslint-enable */ diff --git a/it/typescript/src/app/client/kiota-lock.json b/it/typescript/src/app/client/kiota-lock.json deleted file mode 100644 index cb884c395c..0000000000 --- a/it/typescript/src/app/client/kiota-lock.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "descriptionHash": "20EF99AD604AC7A78DCA5739B05E981E373C6EE21B6D1228B4236028E243FF16760BA2A652767B6D19080C0B4AFE03EA43AF77FCB2BEAB51087C1350A0F6647E", - "descriptionLocation": "../../../../openapi.yaml", - "lockFileVersion": "1.0.0", - "kiotaVersion": "1.13.0", - "clientClassName": "ApiClient", - "clientNamespaceName": "app.client", - "language": "TypeScript", - "usesBackingStore": false, - "excludeBackwardCompatible": true, - "includeAdditionalData": true, - "serializers": [ - "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory", - "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory", - "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory", - "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory" - ], - "deserializers": [ - "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory", - "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory", - "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory" - ], - "structuredMimeTypes": [ - "application/json", - "text/plain;q=0.9", - "application/x-www-form-urlencoded;q=0.2", - "multipart/form-data;q=0.1" - ], - "includePatterns": [], - "excludePatterns": [], - "disabledValidationRules": [] -} \ No newline at end of file diff --git a/it/typescript/src/app/client/models/index.ts b/it/typescript/src/app/client/models/index.ts deleted file mode 100644 index a88aebfdec..0000000000 --- a/it/typescript/src/app/client/models/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// Generated by Microsoft Kiota - -export type MoveType = (typeof MoveTypeObject)[keyof typeof MoveTypeObject]; -export const MoveTypeObject = { - ROCK: "ROCK", - PAPER: "PAPER", - SCISSORS: "SCISSORS", -} as const; -/* tslint:enable */ -/* eslint-enable */ diff --git a/it/typescript/src/app/client/play/index.ts b/it/typescript/src/app/client/play/index.ts deleted file mode 100644 index 5692169f43..0000000000 --- a/it/typescript/src/app/client/play/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// Generated by Microsoft Kiota -// @ts-ignore -import { MoveType, MoveTypeObject } from '../models/'; -// @ts-ignore -import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; - -/** - * Builds and executes requests for operations under /play - */ -export interface PlayRequestBuilder extends BaseRequestBuilder { - /** - * Play a move - * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. - * @returns {Promise} - */ - get(requestConfiguration?: RequestConfiguration | undefined) : Promise; - /** - * Play a move - * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. - * @returns {RequestInformation} - */ - toGetRequestInformation(requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; -} -/** - * Uri template for the request builder. - */ -export const PlayRequestBuilderUriTemplate = "{+baseurl}/play"; -/** - * Metadata for all the requests in the request builder. - */ -export const PlayRequestBuilderRequestsMetadata: RequestsMetadata = { - get: { - uriTemplate: PlayRequestBuilderUriTemplate, - responseBodyContentType: "application/json", - adapterMethodName: "sendEnum", - enumObject: MoveTypeObject, - }, -}; -/* tslint:enable */ -/* eslint-enable */ From 0fe1775e85e5d7031e1ecf4bc0015758d3b8cdb0 Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Mon, 1 Apr 2024 13:51:56 +0100 Subject: [PATCH 6/7] cleanup --- src/Kiota.Builder/Refiners/TypeScriptRefiner.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index c71a061a82..fe32eb4938 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -6,7 +6,6 @@ using Kiota.Builder.CodeDOM; using Kiota.Builder.Configuration; using Kiota.Builder.Extensions; -using Microsoft.Kiota.Http.HttpClientLibrary; namespace Kiota.Builder.Refiners; public class TypeScriptRefiner : CommonLanguageRefiner, ILanguageRefiner @@ -1142,7 +1141,7 @@ protected static void AddEnumObjectUsings(CodeElement currentElement) }); } } - CrawlTree(currentElement!, AddEnumObjectUsings); + CrawlTree(currentElement, AddEnumObjectUsings); } private static void ProcessModelClassProperties(CodeClass modelClass, CodeInterface modelInterface, IEnumerable properties, Func interfaceNamingCallback) From 676f1923b045104a228eda4f10a3634878279c8e Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Tue, 2 Apr 2024 10:05:22 +0100 Subject: [PATCH 7/7] remove unused code --- src/Kiota.Builder/Refiners/TypeScriptRefiner.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index fe32eb4938..6ef8b678b6 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -1103,11 +1103,6 @@ protected static void AddEnumObject(CodeElement currentElement) } CrawlTree(currentElement, AddEnumObject); } - protected static IEnumerable selectEnums(IEnumerable props) - { - return props.Select(static x => x.Type).OfType().Select(static x => x.TypeDefinition).OfType(); - } - protected static void AddEnumObjectUsings(CodeElement currentElement) { if (currentElement is CodeProperty codeProperty && codeProperty.Kind is CodePropertyKind.RequestBuilder && codeProperty.Type is CodeType codeType && codeType.TypeDefinition is CodeClass codeClass)