Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No API descriptions with OWIN #94

Closed
angularsen opened this issue Oct 2, 2014 · 6 comments
Closed

No API descriptions with OWIN #94

angularsen opened this issue Oct 2, 2014 · 6 comments

Comments

@angularsen
Copy link

I'm using the latest MVC and Web Api 5.2.2 on IIS Express and Swashbuckler 4.1.0-rc2.
The web api is set up with OWIN and the only thing special is using app.Map(). See below.
I've read and followed all the setup instructions and troubleshooting tips.

I've tried to debug it and it comes down to this:

  • /swagger/ui/index.html renders but lists no API descriptions
  • GlobalConfiguration.Configuration.Services.GetApiExplorer().ApiDescriptions is empty
  • If I call WebApiConfig.Register() in Global.asax.cs, then it works, but I believe that defeats the purpose of only setting it up in OWIN to separate the two?

I saw a similar issue #57 , but that seemed more about calling swashbuckler's Init() twice. This is about having to call WebApiConfig.Register() twice, or more specifically, setting up the web api routes for both GlobalConfiguration.Configuration and OWIN's HttpConfiguration. I'm solely using Route attributes in my API controllers, but I also tried setting up a default API route and a test API controller with no route attributes.

Have I misunderstood something about how ApiExplorer or how OWIN works? I know this is probably not a swashbuckler issue per se, but that is what I'm trying to use. Suggestions and insight are most welcome!

[assembly: OwinStartup(typeof (Startup))]

namespace InitialForce.LicenseService
{
    public partial class Startup
    {
        [UsedImplicitly]
        public void Configuration(IAppBuilder app)
        {
            try
            {
                ConfigureAuth(app);

                var config = new HttpConfiguration();
                DependencyConfig.RegisterHttp(config);
                FilterConfig.RegisterGlobalFilters(config);
                WebApiConfig.Register(config);

// Tried this too
//                var apiExplorer = new ApiExplorer(config);
//                config.Services.GetApiExplorer().d .Replace(typeof(IApiExplorer), apiExplorer);

// And tried this
//                Swashbuckle.Bootstrapper.Init(config)

// I've also tried not using app.Map()
                app.Map("/api", inner =>
                {
                    inner.UseWebApi(config);
                    inner.UseStageMarker(PipelineStage.MapHandler);
                });
        }
@ahavenscsi
Copy link

Andreas,

Have you enabled the project setting to output an XML Documentation file on build? Without this it just tells you that it is fetching the resource list.

Aaron
From: Andreas Gullberg Larsen [mailto:notifications@github.com]
Sent: Thursday, October 2, 2014 3:03 PM
To: domaindrivendev/Swashbuckle
Subject: [Swashbuckle] No API descriptions with OWIN (#94)

I'm using the latest MVC and Web Api 5.2.2 on IIS Express and Swashbuckler 4.1.0-rc2.
The web api is set up with OWIN and the only thing special is using app.Map(). See below.
I've read and followed all the setup instructions and troubleshooting tips.

I've tried to debug it and it comes down to this:

  • /swagger/ui/index.html renders but lists no API descriptions
  • GlobalConfiguration.Configuration.Services.GetApiExplorer().ApiDescriptions is empty
  • If I call WebApiConfig.Register() in Global.asax.cs, then it works, but I believe that defeats the purpose of only setting it up in OWIN to separate the two?

I saw a similar issue #57#57 , but that seemed more about calling swashbuckler's Init() twice. This is about having to call WebApiConfig.Register() twice, or more specifically, setting up the web api routes for both GlobalConfiguration.Configuration and OWIN's HttpConfiguration. I'm solely using Route attributes in my API controllers, but I also tried setting up a default API route and a test API controller with no route attributes.

Have I misunderstood something about how ApiExplorer or how OWIN works? I know this is probably not a swashbuckler issue per se, but that is what I'm trying to use. Suggestions and insight are most welcome!

[assembly: OwinStartup(typeof (Startup))]

namespace InitialForce.LicenseService

{

public partial class Startup

{

    [UsedImplicitly]

    public void Configuration(IAppBuilder app)

    {

        try

        {

            ConfigureAuth(app);



            var config = new HttpConfiguration();

            DependencyConfig.RegisterHttp(config);

            FilterConfig.RegisterGlobalFilters(config);

            WebApiConfig.Register(config);

// Tried this too

// var apiExplorer = new ApiExplorer(config);

// config.Services.GetApiExplorer().d .Replace(typeof(IApiExplorer), apiExplorer);

// And tried this

// Swashbuckle.Bootstrapper.Init(config)

// I've also tried not using app.Map()

            app.Map("/api", inner =>

            {

                inner.UseWebApi(config);

                inner.UseStageMarker(PipelineStage.MapHandler);

            });

    }


Reply to this email directly or view it on GitHubhttps://github.com//issues/94.

{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Issue on GitHub","action":{"@type":"ViewAction","url":"https://github.com/domaindrivendev/Swashbuckle/issues/94","name":"View Issue"}}

This message was scanned by ESVA and is believed to be clean.
Click here to report this message as spam.http://mail.csisoftwareusa.com/cgi-bin/learn-msg.cgi?id=C55D3107064.AFFFB

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

@angularsen
Copy link
Author

I have not, but note that I do get API descriptions and swagger working if I just call WebApiConfig.Register() in Global.asax.cs, so I don't think it's due to missing XML. Also I believe the XML is optional and only used for extra information?

@ahavenscsi
Copy link

You are totally correct. I had a break point that skewed my quick test.

@ahavenscsi
Copy link

Andreas,

Here is the basic layout of my Startup class from a working webapi owin project.

[assembly: OwinStartup(typeof(Startup))]
namespace REST
{
    /// <summary>
    /// Main startup of the Rest App
    /// </summary>
    public class Startup
    {
        /// <summary>
        /// Where the OWIN pipeline is constructed and configured
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            AutomapperConfig.SetupAutoMapper();

            ConfigOauth(app);

            var config = new HttpConfiguration();

            Swashbuckle.Bootstrapper.Init(config);
            SwaggerConfig.Register();

            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(config);

            app.UseStageMarker(PipelineStage.MapHandler);
        }
    }

@domaindrivendev domaindrivendev added this to the v5.0.0-alpha milestone Oct 27, 2014
@domaindrivendev
Copy link
Owner

Closing due to inactivity. If you haven't already, please look at this section of the readme - https://github.com/domaindrivendev/Swashbuckle#owin-self-hosted

NOTE: For OWIN, or any hosting environment other than standard IIS, you should NOT install the full "Swashbuckle" package. You should just install the Core libraries and apply the manual bootstrapping steps as described in the readme.

@angularsen
Copy link
Author

Thanks, I will try this on my next opportunity. It's been a long while since I touched the project where I tried this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants