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
// We set the Description to the first non-null value we find that matches the status code.
379
-
apiResponseType.Description??=responseMetadataTypes.FirstOrDefault(x =>x.StatusCode==apiResponseType.StatusCode&&x.Descriptionis not null)?.Description;
378
+
// We set the Description to the LAST non-null value we find that matches the status code.
379
+
apiResponseType.Description??=responseMetadataTypes.LastOrDefault(x =>x.StatusCode==apiResponseType.StatusCode&&x.Type==apiResponseType.Type&&x.Descriptionis not null)?.Description;
/// 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
0 commit comments