How do I get ASP.NET Web API working with versioning and the Help Page extension?

前端 未结 3 1242
北恋
北恋 2021-01-31 10:28

I\'ve implemented a versioning framework into my WebAPI application, and would very much like to get it working with the new Help Page extension from Microsoft.

Microsof

3条回答
  •  眼角桃花
    2021-01-31 10:55

    I couldn't figure out how to comment on a post :( I think this should probably be a comment under the marked answer for this question but SDamman is updated and all I needed to do was this

    // enable API versioning                   
    GlobalConfiguration.Configuration.Services.Replace(typeof(System.Web.Http.Dispatcher.IHttpControllerSelector), 
         new SDammann.WebApi.Versioning.RouteVersionedControllerSelector(GlobalConfiguration.Configuration));
    
    GlobalConfiguration.Configuration.Services.Replace(typeof(IApiExplorer), new SDammann.WebApi.Versioning.VersionedApiExplorer(GlobalConfiguration.Configuration));
    

    There is a type called VersionedApiExplorer and it works great. Hope this helps the solution is much easier now.

    EDIT: I realized after trying to get help working again myself that my answer wasn't obvious at all.

    The ONLY thing you need to do to get help pages working is replace the global configs IApiExplorer, that's it. Just do it right after you change the handler per sdammans instructions.

提交回复
热议问题