Closed
Description
openedon Jul 18, 2024
Describe the bug
Calling OpenApiFilterService.CreateFilteredDocument
on a document that does not contain the optional field OpenApiDocument.Components
produces a NullReferenceException
.
OpenApi File To Reproduce
Not an OpenApi File, but the following is enough to trigger it.
var openApiDoc = new OpenApiDocument
{
Info = new()
{
Title = "Test",
Version = "1.0.0"
},
Paths = new()
{
["/test"] = new OpenApiPathItem()
{
Operations = new Dictionary<OperationType, OpenApiOperation>
{
[OperationType.Get] = new OpenApiOperation()
}
}
}
};
var requestUrls = new Dictionary<string, List<string>>()
{
{ "/test", ["GET"] }
};
var filterPredicate = OpenApiFilterService.CreatePredicate(null, null, requestUrls, openApiDoc);
var filteredDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, filterPredicate); // Error!
Expected behavior
It should not fail, because the Components
field is not mandatory. If it's necessary it should throw a more descriptive exception.
Additional context
Add any other context about the problem here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels