-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Suppress default status code response type in api descriptions when e… #4831
Conversation
@@ -382,6 +375,15 @@ private string GetRelativePath(RouteTemplate parsedTemplate) | |||
} | |||
} | |||
|
|||
// Set the default status only when no status has already been set explicitly | |||
if (objectTypes.Count == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you merge the two if
s?
when @rynowak is happy. |
{ | ||
objectTypes[StatusCodes.Status200OK] = type; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this all seems contingent on the objectTypes
what will happen by default if the method returns void
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if an action returns void
, then it would by default not have any apidescriptions...metadata needs to be explicitly decorated ex: https://github.com/aspnet/Mvc/blob/dev/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeWithoutAttributeController.cs#L14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open a bug for this? I don't want to bloat this PR, but it seems wrong that we infer 'default 200' when you a DTO as your return type and 'nothing' when you have void as your return type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure: #4838
…xplicit response types have been provided [Fixes #4823] How to override the default (200) status code with ProducesResponseType
3c16860
to
964d5dc
Compare
…xplicit response types have been provided
[Fixes #4823] How to override the default (200) status code with ProducesResponseType
@rynowak