Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating version specific help documentation pages for ASP.NET Web API application

I am using the WebAPI Versioning package to version my API by the X-Api-Header by using the "VersionHeaderVersionedControllerSelector". I am also using the Microsoft.AspNet.WebApi.HelpPage to autogenerate documentation for the APIs. In order for controller versionign to work, they need to be namespaced with the VersionXYZ as the suffix in the namespace so that the "VersionHeaderVersionedControllerSelector" is able to route the request to the appropriate version of the controller like so:

namespace WEBAPI.Api.Controllers.Version1
{ public class ProductsController : ApiController {} }

namespace WEBAPI.Api.Controllers.Version2
{ public class ProductsController : ApiController {} }

This works as intended but when I look at the generated help pages the ApiDescription is including the "VersionXYZ" suffix from the namespace in the ID (GETapi/Version1.Products) and RelativePath(api/Version1.Products) properties. Ideally what I'd like to do is to have a top level help page which just the API Version numbers and drilling in would show the API the normal way i.e. The ApiDescription.ID = GETapi/Products and the ApiDescription.RelativePath = api/Products

Is there a way to achieve this using the Out of the Box APIs or am I going to need to rollout my own implementation of ApiExplorer

like image 681
Abhijeet Patel Avatar asked Feb 02 '13 23:02

Abhijeet Patel


People also ask

Which one from the following will run on top of ASP Net Web API help pages?

NuGet packages (36) A simple Test Client built on top of ASP.NET Web API Help Page.

Is versioning possible in Web API?

As the application grows and business need increase, Versioning of the API is one of the difficult and important part of the API as it makes the API backward compatible. We can do Versioning in ASP.NET Web API with URI, QueryString, Custom Headers and Accept Header parameters, etc.


1 Answers

Check out this answer Get Help page works with Api Versioning

Make sure you have configure the versioning right, and you need to get a documentation XML file from your project XXXX.Api.v1 project and place it in the bin folder of the XXXX.Api project.

like image 179
Philip Ding Avatar answered Nov 02 '22 14:11

Philip Ding