This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new attribute ProducesResponseTypeAttribute to enable ApiExplor…
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
- Loading branch information
Showing
14 changed files
with
627 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/Microsoft.AspNetCore.Mvc.ApiExplorer/ApiResponseFormat.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// 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. | ||
/// Possible format for an <see cref="ApiResponseType"/>. | ||
/// </summary> | ||
public class ApiResponseFormat | ||
{ | ||
/// <summary> | ||
/// The formatter used to output this response. | ||
/// Gets or sets the formatter used to output this response. | ||
/// </summary> | ||
public IOutputFormatter Formatter { get; set; } | ||
|
||
/// <summary> | ||
/// The media type of the response. | ||
/// Gets or sets the media type of the response. | ||
/// </summary> | ||
public string MediaType { get; set; } | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Microsoft.AspNetCore.Mvc.ApiExplorer/ApiResponseType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
|
||
namespace Microsoft.AspNetCore.Mvc.ApiExplorer | ||
{ | ||
/// <summary> | ||
/// Possible type of the response body which is formatted by <see cref="ApiResponseFormats"/>. | ||
/// </summary> | ||
public class ApiResponseType | ||
{ | ||
/// <summary> | ||
/// Gets or sets the response formats supported by this type. | ||
/// </summary> | ||
public IList<ApiResponseFormat> ApiResponseFormats { get; set; } = new List<ApiResponseFormat>(); | ||
|
||
/// <summary> | ||
/// Gets or sets <see cref="ModelBinding.ModelMetadata"/> for the <see cref="Type"/> or null. | ||
/// </summary> | ||
/// <remarks> | ||
/// Will be null if <see cref="Type"/> is null or void. | ||
/// </remarks> | ||
public ModelMetadata ModelMetadata { get; set; } | ||
|
||
/// <summary> | ||
/// 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 | ||
/// <see cref="ProducesAttribute"/> or <see cref="ProducesResponseTypeAttribute"/> on an action method | ||
/// to specify a response type. | ||
/// </remarks> | ||
public Type Type { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the HTTP response status code. | ||
/// </summary> | ||
public int StatusCode { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.