Support for Custom Response Header #895
-
Our organization has a requirement to include the planned retirement date for a deprecated version. This information would be included in the response header, much like the deprecated-versions and supported-versions headers are now. I was hoping to simply extend the existing functionality, but I am not seeing any documentation, or even examples, of how to do that. Can anyone tell me if this is possible, or do I need to roll my own so to speak? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 13 replies
-
Starting in I'm behind on updating the documentation to fully outline the feature, but there is an open issue tracking that. You can see an example of how to use it here or take a look at the tests. There is also now a client library to complement Happy to answer any more questions about how the feature works. In general, you just configure it from the |
Beta Was this translation helpful? Give feedback.
-
After switching to the new version (v6.1), I am getting a Swashbuckle error: Here's what my controller code looks like. The new version basically does nothing. This is simply to test the versioning functionaity. [ApiController]
[Route("/")]
[ApiVersion(ApiVersions.V1_0, Deprecated = ApiVersions.V1_0_Deprecated)]
[ApiVersion(ApiVersions.V1_1, Deprecated = ApiVersions.V1_1_Deprecated)]
public class QueryController : ControllerBase
{
/// <summary>
/// GET request that returns a path of nodes downstream starting from the node specified as a parameter
/// </summary>
/// <returns>
/// A path type which is derived from a list of Nodes and Relationships
/// </returns>
/// <param name="node_id">Name of starting node</param>
/// <param name="limit_hops">Max number of hops to traverse from <paramref name="node_id"/></param>
/// <param name="limit_nodes">Max number of paths to traverse</param>
[Route("/DownstreamPath/{node_id}")]
[HttpGet]
[MapToApiVersion(ApiVersions.V1_0)]
[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.Filter | AllowedQueryOptions.Select | AllowedQueryOptions.Expand)]
public async Task<Models.v1_0.ApiResponse<Edge>> DownstreamPath(string node_id, int limit_hops = 2, int limit_nodes = 100)
{
// v1.0 code here
}
/// <summary>
/// Version 1.1 of GET request that returns a path of downstream nodes
/// </summary>
/// <returns>
/// An error message saying this version hasn't yet been implemented
/// </returns>
[Route("/DownstreamPath/{node_id}")]
[HttpGet]
[MapToApiVersion(ApiVersions.V1_1)]
[EnableQuery(AllowedQueryOptions = AllowedQueryOptions.Filter | AllowedQueryOptions.Select | AllowedQueryOptions.Expand)]
public Task<Models.v1_1.ApiResponse<Edge>> NewDownstreamPath(string node_id, int limit_hops = 2, int limit_nodes = 100)
{
// v1.1 code here
}
} |
Beta Was this translation helpful? Give feedback.
-
Here is a working example of multiple versions on the same controller. hosted here |
Beta Was this translation helpful? Give feedback.
Starting in
6.0
this is now possible. The feature Sunset Policies implements RFC 8594, which satisfies this requirement. RFC 8288 is also supported so that you can provide additional links to published policies. It's worth noting that an API doesn't have to be deprecated to advertise a sunset date. You might know ahead of time that a supported API will deprecate and then fully sunset well in advance (ex: a year from now).I'm behind on updating the documentation to fully outline the feature, but there is an open issue tracking that. You can see an example of how to use it here or take a look at the tests.
There is also now a client library to complement
HttpClient
which can detect this in…