Skip to content

Commit d28a74f

Browse files
committed
Improve comments on existing test
1 parent e39c52d commit d28a74f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ public async Task MapOpenApi_ShouldRetrieveOptionsInACaseInsensitiveManner()
181181
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
182182
var responseString = Encoding.UTF8.GetString(responseBodyStream.ToArray());
183183

184-
// When we receive an OpenAPI document, we use an OptionsMonitor to retrieve named options that equal the requested document name.
185-
// This is case-sensitive. If the document doesn't exist, the options monitor return a default instance, in which the OpenAPI version is set to v3.
184+
// When we receive an OpenAPI document, we use an OptionsMonitor to retrieve OpenAPI options which are stored with a key equal the requested document name.
185+
// This key is case-sensitive. If the document doesn't exist, the options monitor return a default instance, in which the OpenAPI version is set to v3.
186+
// This could cause bugs! You'd get your document, but depending on the casing you used in the document name you passed to the function, you'll receive different OpenAPI document versions.
187+
// We want to prevent this from happening. Therefore:
186188
// By setting up a v2 document on the "casesensitive" route and requesting it on "CaseSensitive",
187189
// we can test that the we've configured the options monitor to retrieve the options in a case-insensitive manner.
188190
// If it is case-sensitive, it would return a default instance with OpenAPI version v3, which would cause this test to fail!
189-
// However, if it would return the v2 instance, the test would pass!
191+
// However, if it would return the v2 instance, which was configured on the lowercase - case-insensitive - documentname, the test would pass!
190192
// For more info, see OpenApiEndpointRouteBuilderExtensions.cs
191193
Assert.StartsWith("{\n \"swagger\": \"2.0\"", responseString);
192194
}

0 commit comments

Comments
 (0)