Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions src/Refitter.Core/RefitGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,7 @@ public static async Task<RefitGenerator> CreateAsync(RefitGeneratorSettings sett

private static async Task<OpenApiDocument> 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,
Expand Down
5 changes: 3 additions & 2 deletions src/Refitter.Tests/Examples/ColonsInPathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading