The swagger files are embedded resources inside the ServiceStack.Api.OpenApi.dll as such, it will always be “published”.
If it’s returning a 404, I’m assuming either interfering with the pre-configured VirtualFileSources or something is short-circuiting the request.
Find out what’s returning the 404, i.e. whether it’s from IIS or ServiceStack which you should be able to tell from the Powered-By HTTP Response Header.
Looks like something is handling the Request before it can reach ServiceStack.
Try moving your app.UseServiceStack(new AppHost()) middleware higher in the pipeline. Do you have any /swagger-ui folders, if so try renaming it to see if that’s the cause of the conflict.
Ok so this is a .NET Framework App, in that case I’m not sure why it’s returning a 404, are you running any custom IIS handlers that could interfere with it, or have a local /swagger-ui/ folder?
Yes, it is a .NET Framework app. In the same PC there is another apphost (self hosted) with SwaggerUI enabled (and it works), the one with the problem is hosted within an IIS 10 istance where there is no customer handlers nor swagger-ui folder.
This template doesn’t run at all, can you send a link to a new project that’s updated to use the latest ServiceStack v8.2.2 Version running at least .NET Framework v4.7.2.
Note, you don’t need to check in any /bin or /obj folders with your projects as they’ll be restored by VS when building the project.
I just download the template (that use last version of ServiceStack), add the reference to OpenAPI and it works as a charm on my local IIS Express. Same project published on my IIS 10 environment doesn’t work.
How is suppose to be setup the website in IIS in order to discover the embedded resources? I created the virtual directory “swagger-ui” on IIS but still resources are not discovered.
Remove any /swagger-ui folders or handlers in your project or IIS, IIS shouldn’t have anything named /swagger-ui that conflicts with it, as long as the /swagger-ui/* requests reach ServiceStack, it should handle it.
The issue sounds like IIS or ASP .NET is handling the request and returning a 404 before the request can reach ServiceStack, I can’t tell what that is from here.
Alternatively if you can’t figure it out, you can try copying the entire /swagger-ui folder in your /wwwroot, which your IIS or ASP.NET can serve directly instead.
Easiest way to do that would be to download the a zip of the GitHub Repo ServiceStack.zip, extracting it and copying the /ServiceStack/src/ServiceStack.Api.OpenApi/swagger-ui folder to your /wwwroot.
Easiest way to do that would be to download the a zip of the GitHub Repo ServiceStack.zip, extracting it and copying the /ServiceStack/src/ServiceStack.Api.OpenApi/swagger-ui folder to your /wwwroot .
Once I put the swagger-ui folder on my site root It start to works as expected. It is not be best solution, but it works, so I will keep it.