Skip to content
This repository

Routes dont appear in ApiExplorer (WebApi RC) #86

Closed
mckn opened this Issue June 19, 2012 · 21 comments

3 participants

Marcus Andersson Tim McCall Brent Pabst
Marcus Andersson
mckn commented June 19, 2012

I tried to use the ApiExplorer to generate a documentation for my API. But the routes that I have registered with AttributeRouting isn't detected by the ApiExplorer.

I don't know why but if I add the routing by using the routes.MapHttpRoute(...) method they all appear as they should.

Tim McCall
Owner

This might be related to #83

Marcus Andersson
mckn commented June 21, 2012

I'm not sure. I think it could be because the ApiExplorer search for IHttpRoutes and, correct me if I'm wrong, AttributeRouting uses ordinary routes that don't implement that interface?

http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/de16aded54ab#src%2fSystem.Web.Http%2fDescription%2fApiExplorer.cs

Tim McCall
Owner

I don't recall any IHttpRoute in the source. Will look into this further. Sorry for the delay, been away from the macine for a few weeks.

Marcus Andersson
mckn commented July 09, 2012

I think we need to use the same code in AttributeRouting.Web.Http as in AttributeRouting.Web.Http.SelfHost. It looks like you use the HttpRoute there and that class implements the IHttpRoute.

Tim McCall
Owner

Yes, I think you are correct. Looking into the webstack source and it seems that AR should be building a System.Web.Http.WebHost.Routing.HostedHttpRoute. But this object is internal! So will have to go through the source and see what we can use, if this object is public in the nightly builds, etc....

Tim McCall
Owner

Give the code in master a try if you'd like. I believe this might have been resolved by 2.4.2.

Marcus Andersson
mckn commented August 06, 2012

I tried to do the same in a ApiController but I couldn't get the explorer to detect my routes.

Edit: Yes, I updated to the 2.4.2 version.

Tim McCall
Owner

Interesting. I'm still working to resolve the ApiExplorer integration, FYI.

Tim McCall
Owner

Try 2.4.3. I just pushed to nuget. If it still isn't working for you, you can give me more details about what you are doing and I can try and help. I do have a demo of using ApiExplorer in AttributeRouting.Tests.Web, FYI.

Marcus Andersson
mckn commented August 07, 2012

Now it's working! I updated to 2.4.3 version and it worked. Thanks alot, what did you change?

Marcus Andersson mckn closed this August 07, 2012
Tim McCall
Owner

Just changed some underlying bits to tie into the RC version of Web API properly (ie: copied what MS did). But so glad it's working!

Tim McCall
Owner

Also note that you're going to encounter the problems mentioned in #102. But I am working closely with the ASP.NET team to resolve all the remaining Web API goofiness so AR can be a default package in new web projects.

Brent Pabst

Hi, running v2.5.3 and .NET 4.5 and I'm still not able to get the ApiExplorer to populate my routes. In all fairness I am not storing the actuall code files in the default controllers folder but I didn't think that would matter. Is there a specific set of instructions or things you have to do to get the ApiExplorer to load the AR routes?

Tim McCall
Owner
Brent Pabst

Yea, tried looking into that but even with copying your code in over mine still no joy. It may simply be an issue with the RTM bits versus RC. Either way, I've actually rethought how I want to generate help pages and actually determined I'd rather create a web service that provides a JSON feed of the entire set of services or per controller and then display that on a different application. Separates the API application/service from the marketing and CMS content.

Tim McCall
Owner
Brent Pabst

Hi,

Just following up to see if this was ever investigated. I was able to create a brand new project and everything works as expected. However, my existing project does not but that could be for god knows what reason. I have a sample project for others but it doesn't look like I can attach it here.

Tim McCall
Owner

No. It fell of the table. Reading over the discussion, and knowing that AR and ApiExplorer have some other issues anyway, I'd like a sample project recreating the issue (could just pop it into a github repo for me to clone). It seems really inconsistent and I have frankly no idea what could be happening at this point or why the ApiExplorer is misbehaving.

Brent Pabst

Yep, agreed. I can't seem to understand what the difference is either. I have a feeling it has to do with how/when the routes are added to the Routing Table thing.

I'm going to try setting up my base project and add things to match what is currently in place and see when the behavior goes nuts.

If I can get it to do so I'll get a project uploaded for you to take a look at.

Tim McCall
Owner

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.