Note that there are some explanatory texts on larger screens.

plurals
  1. POSwagger with Service Stack not working
    primarykey
    data
    text
    <p>I am trying to implement Swagger with Service Stack. I've installed service stack with swagger using nuget. Current DLL versions are reported as 3.9.56.0 mostly.</p> <p>I am trying to follow the example provided at... <a href="https://github.com/ServiceStack/ServiceStack.UseCases/tree/master/SwaggerHelloWorld" rel="nofollow">https://github.com/ServiceStack/ServiceStack.UseCases/tree/master/SwaggerHelloWorld</a></p> <p>and the instrucstion appear fairly fool-proof...</p> <pre><code>Plugins.Add(new ServiceStack.Api.Swagger.SwaggerFeature()); </code></pre> <p>goes into the 'Configure' method after I've installed via nuget (as the documentation instructs), then I've added [ApiMember] and [Api] tags, along with changes to the [Route] tags to add Summary and Notes</p> <p>but when I visit <code>~/swagger-ui/index.html</code> i get the error</p> <pre><code>Please specify the protocol for ../api </code></pre> <p>My api sits at <code>~/api</code>, and I have a single method at the moment (Hello World) sitting at <code>~api/Hello/{name}</code> which returns JSON and works ok.</p> <p>if I visit <code>~api</code>i get the message <code>Handler for Request not found:</code> with a stack trace type output.</p> <p>What am I doing wrong? The instructions to enable swagger appear really straight forward, and detailed instructions appear to be lacking, probably because it should 'just work', please help! </p> <p>Update to address Esker...</p> <p>Stack trace @ myhost:54011/api</p> <pre><code>Handler for Request not found: Request.ApplicationPath: / Request.CurrentExecutionFilePath: /api Request.FilePath: /api Request.HttpMethod: GET Request.MapPath('~'): D:\Starteam\Private\user\web\ServiceStackSwagger\ServiceStackSwagger\ Request.Path: /api Request.PathInfo: Request.ResolvedPathInfo: /api Request.PhysicalPath: D:\Starteam\Private\user\web\ServiceStackSwagger\ServiceStackSwagger\api Request.PhysicalApplicationPath: D:\Starteam\Private\user\web\ServiceStackSwagger\ServiceStackSwagger\ Request.QueryString: Request.RawUrl: /api Request.Url.AbsoluteUri: http://localhost:54011/api Request.Url.AbsolutePath: /api Request.Url.Fragment: Request.Url.Host: localhost Request.Url.LocalPath: /api Request.Url.Port: 54011 Request.Url.Query: Request.Url.Scheme: http Request.Url.Segments: System.String[] App.IsIntegratedPipeline: True App.WebHostPhysicalPath: D:\Starteam\Private\user\web\ServiceStackSwagger\ServiceStackSwagger App.WebHostRootFileNames: [global.asax,global.asax.cs,helloservice.cs,jquery-1.10.2.js,packages.config,servicestackswagger.csproj,servicestackswagger.csproj.user,web.config,web.debug.config,web.release.config,app_data,app_start,bin,controllers,dto,models,obj,properties,swagger-ui,views] App.DefaultHandler: metadata App.DebugLastHandlerArgs: GET|/api|D:\Starteam\Private\user\web\ServiceStackSwagger\ServiceStackSwagger\api </code></pre> <p>Also, "Please specify protocol' is a swagger error, displayed onscreen in html underneath the aforementioned 'textbox to change discovery url' </p> <p>and the DLL versions are 'mostly' the same because ServiceStack.Redis is version 3.9.57.0, but I'm not using that, so 'mostly'</p> <p>Update... My Solution</p> <p>I needed this in my web.config file inside of the <code>&lt;configuration&gt;</code> tag, I had previously not included the <code>&lt;location path="api"&gt;</code> bit.</p> <pre><code>&lt;!-- ServiceStack: CustomPath /api --&gt; &lt;location path="api"&gt; &lt;system.web&gt; &lt;httpHandlers&gt; &lt;add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/&gt; &lt;/httpHandlers&gt; &lt;/system.web&gt; &lt;!-- Required for IIS 7.0 --&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;validation validateIntegratedModeConfiguration="false" /&gt; &lt;handlers&gt; &lt;add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /&gt; &lt;/handlers&gt; &lt;/system.webServer&gt; &lt;/location&gt; </code></pre> <p>also... I had set up my 'routes' as such...</p> <pre><code>//INCORRECT [Route("/api/Hello/{name}", Summary = @"N031'5 ServiceStackSwagger thingy", Notes = "Some more info in here cause these are notes")] public class Hello : IReturn&lt;HelloResponse&gt; </code></pre> <p>but that messed with swagger's functionality, it needed to be...</p> <pre><code>//CORRECT [Route("/Hello/{name}"... </code></pre> <p>with the 'api' bit REMOVED, and now everything is working.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload