diff --git a/src/Refitter.Core/RefitGenerator.cs b/src/Refitter.Core/RefitGenerator.cs index 1dd333adf..8f8a80f68 100644 --- a/src/Refitter.Core/RefitGenerator.cs +++ b/src/Refitter.Core/RefitGenerator.cs @@ -32,32 +32,7 @@ public static async Task CreateAsync(RefitGeneratorSettings sett private static async Task GetOpenApiDocument(RefitGeneratorSettings settings) { - var specialCharacters = new[] - { - ":" - }; - - return specialCharacters.Aggregate( - await OpenApiDocumentFactory.CreateAsync(settings.OpenApiPath), - SanitizePath); - } - - private static OpenApiDocument SanitizePath( - OpenApiDocument openApiDocument, - string stringToRemove) - { - var paths = openApiDocument.Paths.Keys - .Where(pathKey => pathKey.Contains(stringToRemove)) - .ToArray(); - - foreach (var path in paths) - { - var value = openApiDocument.Paths[path]; - openApiDocument.Paths.Remove(path); - openApiDocument.Paths.Add(path.Replace(stringToRemove, string.Empty), value); - } - - return openApiDocument; + return await OpenApiDocumentFactory.CreateAsync(settings.OpenApiPath); } private static void ProcessContractFilter(OpenApiDocument openApiDocument, bool removeUnusedSchema, string[] includeSchemaMatches, diff --git a/src/Refitter.Tests/Examples/ColonsInPathTests.cs b/src/Refitter.Tests/Examples/ColonsInPathTests.cs index c8e835800..4b227b51e 100644 --- a/src/Refitter.Tests/Examples/ColonsInPathTests.cs +++ b/src/Refitter.Tests/Examples/ColonsInPathTests.cs @@ -52,11 +52,12 @@ public async Task Can_Generate_Code() } [Fact] - public async Task Generates_Path_Without_Colons() + public async Task Generates_OperationName_Without_Colons() { var generatedCode = await GenerateCode(); using var scope = new AssertionScope(); - generatedCode.Should().NotContain("/:"); + generatedCode.Should().NotContain(":OrderItems("); + generatedCode.Should().Contain("\"/orders/{orderId}/:orderItems/{orderItemId}\""); } [Fact]