Hi wondering if there is any trick to getting /swagger-ui/index.html to reference the "local" /resources url by default rather than the petstore.
ServiceStack.Api.OpenApi open services resources by default. Here is the code in SwaggerFeature which does this. What is your configuration of SwaggerFeature? Did you replace default
index.html with custom one?
I did not replace the index.html file.. and not setting any configuration...
This is on dotnetcore if that matters.
For Swagger UI I would recommend to use ServiceStack.Api.OpenApi instead because OpenApi uses more recent version of Swagger UI and Open API specification (formerly named as Swagger), but if you want to use SwaggerFeature, I made a HelloSwagger sample which demonstrates the project with Swagger UI enabled.
To use it you need to run following commands:
git clone https://github.com/xplicit/HelloSwagger
Then open in browser
http://localhost:5000/swagger-ui/ and you will see the list of services (It contains
If you want to switch to OpenApi later you need to make this changes:
<PackageReference Include="ServiceStack.Api.Swagger.Core" Version="1.0.*" />
<PackageReference Include="ServiceStack.Api.OpenApi.Core" Version="1.0.*" />
And in HelloSwagger.cs change
(also you need to change namespaces in usings)
$ dotnet --info
.NET Command Line Tools (1.0.4)
Commit SHA-1 hash: af1e6684fd
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
Base Path: /usr/local/share/dotnet/sdk/1.0.4
I don't have Mac right now near me to check the sample on OS X, but looks like current directory where the project is running differs from
Are you executing
dotnet run from
HelloSwagger/src/HelloSwagger directory and then open
I tested it on Ubuntu 16.04, here is running project http://188.8.131.52:5000/swagger-ui/
I've just tried @xplicit's HelloSwagger in OSX Yosemite using latest .NET Core from https://www.microsoft.com/net/core#macos and the Swagger UI working as expected:
So not sure what problem you're running into, maybe you can try deleting your NuGet cache?
Just to be clear you're using the Swagger UI link in the
/metadata page right? e.g
dotnet nuget locals all --clear
did the trick. Thanks!
(What is strange is this happened on my localhost as well as our kubernetes cluster... but oh well, working now)
For posterity's sake, wanted to reply back that the underlying issue we were having was not using exactly the right url - so if you go to
(no trailing slash) you get a bad page, and if you go to
it doesn't re-write the page for your local api.
is all good.
This is also the URL that is on the metadata page.