You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting the Description in a ProducesResponseTypeAttribute works correctly for Minimal API (#60539)
* Improve existing test
* Add more tests for regression
* Add tests which now succeed
* Add more tests
* Set the description to the final one encountered and add tests
* Use local method as requested by PR comment
* Fix comment
/// Setting the description grabs the LAST description.
380
+
// To validate this, we add multiple ProducesResponseType to validate that it only grabs the LAST ONE.
381
+
/// </summary>
382
+
[Fact]
383
+
publicvoidAddsResponseDescription_UsesLastOne()
384
+
{
385
+
conststringexpectedCreatedDescription="A new item was created";
386
+
conststringexpectedBadRequestDescription="Validation failed for the request";
387
+
388
+
varapiDescription=GetApiDescription(
389
+
[ProducesResponseType(typeof(int),StatusCodes.Status201Created,Description="First description")]// The first item is an int, not a timespan, shouldn't match
390
+
[ProducesResponseType(typeof(int),StatusCodes.Status201Created,Description="Second description")]// Not a timespan AND not the final item, shouldn't match
391
+
[ProducesResponseType(typeof(TimeSpan),StatusCodes.Status201Created,Description=expectedCreatedDescription)]// This is the last item, which should match
Copy file name to clipboardExpand all lines: src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiDocumentService/OpenApiDocumentServiceTests.Responses.cs
0 commit comments