Swagger.Net icon indicating copy to clipboard operation
Swagger.Net copied to clipboard

Support AttributeRouting

Open jamesholcomb opened this issue 12 years ago • 3 comments

Trying to get your included sample to work with AR by adding these to the BlogPostsController

[RoutePrefix("api/BlogPosts")]
[DefaultHttpRouteConvention]

and using the following AR routing setup

public static void RegisterRoutes(HttpRouteCollection routes) {           
// See http://github.com/mccalltd/AttributeRouting/wiki for more options.
// To debug routes locally using the built in ASP.NET development server, go to /routes.axd

        routes.MapHttpAttributeRoutes(config =>
            {
                config.AutoGenerateRouteNames = true;
                config.UseLowercaseRoutes = true;
                config.AddRoutesFromAssembly(Assembly.GetExecutingAssembly());
                config.RouteNameBuilder = RouteNameBuilders.Unique;
            }
        );
    }

But only the GET endpoint shows up in the Swagger UI. If you check /routes.axd, you can see the list of route names and urls.

jamesholcomb avatar Jan 16 '13 21:01 jamesholcomb

Hey James.

Sorry for delay. I'll try to look at this tonight but FYI, attribute routing can be really slow. Then team I'm working with had to ditch it for performance reasons. But the have 30 or 40 controllers and it might be fixed in latest release.

Thx. Dan

Sent from my iPad

On Jan 16, 2013, at 4:27 PM, James Holcomb [email protected] wrote:

Trying to get your included sample to work with AR by adding these to the BlogPostsController

[RoutePrefix("api/BlogPosts")] [DefaultHttpRouteConvention]

and using the following AR routing setup

public static void RegisterRoutes(HttpRouteCollection routes) { // See http://github.com/mccalltd/AttributeRouting/wiki for more options. // To debug routes locally using the built in ASP.NET development server, go to /routes.axd

    routes.MapHttpAttributeRoutes(config =>
        {
            config.AutoGenerateRouteNames = true;
            config.UseLowercaseRoutes = true;
            config.AddRoutesFromAssembly(Assembly.GetExecutingAssembly());
            config.RouteNameBuilder = RouteNameBuilders.Unique;
        }
    );
}

But only the GET endpoint shows up in the Swagger UI. If you check /routes.axd, you can see the list of route names and urls.

— Reply to this email directly or view it on GitHubhttps://github.com/danieleli/Swagger.Net/issues/2.

danieleli avatar Jan 20 '13 18:01 danieleli

Any progress? I don't have any performance issues with AR. I have 10 controllers.

jamesholcomb avatar Jan 26 '13 01:01 jamesholcomb

Hey, I'm wrapping up some OAuth stuff today but I'm back on this full time for my project after that. So I should have something for ya by EOD tomorrow.

danieleli avatar Jan 29 '13 14:01 danieleli