From 5f6cd3052361edcc3bfa79fc15458485432efb6e Mon Sep 17 00:00:00 2001 From: Jaliya Udagedara Date: Thu, 8 Aug 2024 19:55:11 +1200 Subject: [PATCH] Remove duplicated code. --- tools/code/integration.tests/Api.cs | 42 +---------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/tools/code/integration.tests/Api.cs b/tools/code/integration.tests/Api.cs index 8f92c345..d49fc73c 100644 --- a/tools/code/integration.tests/Api.cs +++ b/tools/code/integration.tests/Api.cs @@ -415,7 +415,7 @@ static async ValueTask writeInformationFile(ApiName name, ApiType type, string p var apiName = getApiName(name, revision, index); var informationFile = ApiInformationFile.From(apiName, serviceDirectory); var rootApiName = ApiName.GetRootName(name); - var dto = getDto(rootApiName, type, path, version, revision); + var dto = GetDto(rootApiName, type, path, version, revision); await informationFile.WriteDto(dto, cancellationToken); } @@ -451,46 +451,6 @@ await specificationOption.IterTask(async x => await specificationFile.WriteSpecification(BinaryData.FromString(contents), cancellationToken); }); } - - static ApiDto getDto(ApiName name, ApiType type, string path, Option version, ApiRevision revision) => - new ApiDto() - { - Properties = new ApiDto.ApiCreateOrUpdateProperties - { - // APIM sets the description to null when it imports for SOAP APIs. - DisplayName = name.ToString(), - Path = path, - ApiType = type switch - { - ApiType.Http => null, - ApiType.Soap => "soap", - ApiType.GraphQl => null, - ApiType.WebSocket => null, - _ => throw new NotSupportedException() - }, - Type = type switch - { - ApiType.Http => "http", - ApiType.Soap => "soap", - ApiType.GraphQl => "graphql", - ApiType.WebSocket => "websocket", - _ => throw new NotSupportedException() - }, - Protocols = type switch - { - ApiType.Http => ["http", "https"], - ApiType.Soap => ["http", "https"], - ApiType.GraphQl => ["http", "https"], - ApiType.WebSocket => ["ws", "wss"], - _ => throw new NotSupportedException() - }, - ServiceUrl = revision.ServiceUri.ValueUnsafe()?.ToString(), - ApiRevisionDescription = revision.Description.ValueUnsafe(), - ApiRevision = $"{revision.Number.ToInt()}", - ApiVersion = version.Map(version => version.Version).ValueUnsafe(), - ApiVersionSetId = version.Map(version => $"/apiVersionSets/{version.VersionSetName}").ValueUnsafe() - } - }; } public static void ConfigureValidatePublishedApis(IHostApplicationBuilder builder)