Reputation: 2197
I am trying to get Swagger to work with ServiceStack. The web server is located behind a Firewall and accessed from the Internet (my.domain.de:80). Requests are then forwarded to the web server on Port 8070.
When visiting the swagger page it is able to access /api/resources
and retrieve the List of ServiceMethods, but then fails to retrieve the List of Operations.
When I use fiddler to inspect the result I see that he /api
is missing so that swagger tries to get the List of Operations from /resources/ServiceName
instead of /api/resources/ServiceName
.
The Swagger-UI gives me the following error message:
Unable to read api 'ServiceName' from path http://my.domain.de/resource/ServiceName (server returned Not Found)
SwaggerConfig:
discoveryUrl:"../../api/resources",
ServiceStack Config:
WebHostUrl = "http://my.domain.de"
Update(2)
If I dont set the WebHostUrl the BasePath in the initial response from ServiceStacks resources service contains the portnumber from the webserver basePath=http://my.domain.de:8060/api
. But on the Firewall this port is not reachable, nor do we want it to be reachable.
web.config
:
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
Update
in the Inital response the basepath is:
basePath=http://my.domain.de
and by my.domain.de I mean a real world url which is just the hostname without port, url-path, querystring or fragment (I acctually checked wikipedia for the correct names ;)
I have found this other question on StackOverflow, but it did not help me. Swagger with Service Stack not working
How can I get ServiceStack/Resources Service to either add /api
for its returned ServiceList?
Upvotes: 4
Views: 1470
Reputation: 131
Colleague of op here.
I spent some time researching this problem and I believe the issue is a bug in ServiceStack's swagger support.
See here:
https://github.com/ServiceStack/ServiceStack/pull/800
Quote:"When set, use webhosturl for base url in swagger and metadata links"
It is implemented correctly for metadata, but not for swagger.
Line 52 in SwaggerResourcesService.cs overrides the baseurl with the WebHostUrl if it is set, but does not combine with the real path as the implementation in metadata does:
Upvotes: 1