Skip to content

Commit

Permalink
Merge pull request #170 from renjithnew2/fix-for-documentname-not-pro…
Browse files Browse the repository at this point in the history
…pagated-in-the-clone

Fix for DocumentName not propagated in the clone.
  • Loading branch information
m-wild authored Jan 16, 2024
2 parents 5255a55 + 1d56c76 commit 74d4775
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Saunter/AsyncApiSchema/v2/AsyncApiDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public AsyncApiDocument Clone()
clone.Info = Info;
clone.Id = Id;
clone.DefaultContentType = DefaultContentType;
clone.DocumentName = DocumentName;
clone.Channels = Channels.ToDictionary(p => p.Key, p => p.Value);
clone.Servers = Servers.ToDictionary(p => p.Key, p => p.Value);
foreach (var tag in Tags)
Expand Down
17 changes: 17 additions & 0 deletions test/Saunter.Tests/Generation/Filters/DocumentFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ public void DocumentFilterIsAppliedToAsyncApiDocument()
document.Channels.ShouldContainKey("foo");
}

[Fact]
public void DocumentNameIsAppliedToAsyncApiDocument()
{
// Arrange
const string documentName = "Test Document";
var options = new AsyncApiOptions();
options.AsyncApi.DocumentName = documentName;
var documentGenerator = new DocumentGenerator();

// Act
options.AddDocumentFilter<ExampleDocumentFilter>();
var document = documentGenerator.GenerateDocument(new[] { GetType().GetTypeInfo() }, options, options.AsyncApi, ActivatorServiceProvider.Instance);

// Assert
document.ShouldNotBeNull();
document.DocumentName.ShouldBe(documentName);
}

private class ExampleDocumentFilter : IDocumentFilter
{
public void Apply(AsyncApiDocument document, DocumentFilterContext context)
Expand Down

0 comments on commit 74d4775

Please sign in to comment.