-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Added new attribute ProducesResponseTypeAttribute to enable ApiExplor… #4269
Conversation
/// Will be null if the action returns no response, or if the response type is unclear. Use | ||
/// <c>ProducesAttribute</c> on an action method to specify a response type. | ||
/// </remarks> | ||
public Type ResponseType { get; set; } |
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.
Let's change this to just Type
and ModelMetadata
for consistency with https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.ApiExplorer/ApiParameterDescription.cs
this is overall looking good ⌚ |
3a7c44b
to
f41a511
Compare
🆙 📅 |
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.AspNetCore.Mvc.Formatters; | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ApiExplorer | ||
{ | ||
/// <summary> | ||
/// Represents a possible format for the body of a response. | ||
/// </summary> | ||
public class ApiResponseFormat |
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.
This needs new docs yo
var responseType = Assert.Single(description.SupportedResponseTypes | ||
.Where(respData => respData.ResponseType == type && respData.StatusCode == 200)); | ||
Assert.Equal(4, responseType.ResponseFormats.Count); | ||
Assert.Single(responseType.ResponseFormats, frmt => frmt.MediaType == "text/json"); |
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.
don't abbreviate
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.
This is still here
Looking overall good, lots of little cleanup things to do ⌚ |
public int StatusCode { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public void SetContentTypes(MediaTypeCollection contentTypes) |
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.
Why do we need to implement this at all? I understand that it causes no harm, but it's confusing that it has this here.
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.
ApiExplorer would currently look for IApitResponseMetadataProvider
and probably you are suggesting to break this interface up into 2?
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.
Yeah, we're not changing this.
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 we make it an explicit implementation just so it doesn't show up in the regular API surface?
eb1d3dd
to
bef2a4f
Compare
🆙 📅 |
@@ -6,18 +6,18 @@ | |||
namespace Microsoft.AspNetCore.Mvc.ApiExplorer | |||
{ | |||
/// <summary> | |||
/// Represents a possible format for the body of a response. | |||
/// Possible format for an <see cref="ApiResponseType"/>. |
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.
Potential format
?
⌚ |
80b0069
to
0637080
Compare
/// Gets or sets the CLR data type of the response or null. | ||
/// </summary> | ||
/// <remarks> | ||
/// Will be null if the action returns no response, or if the response type is unclear. Use |
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.
<c>null</c>
if the ...
when @rynowak is happy. |
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
0637080
to
3670144
Compare
…er to expose response type and StatusCode.
[Fixes #4101] StatusCode Metadata
@rynowak