Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger run locally but not on IIS, not resolving base path

I am setting up Swagger for documenting my API.

I have set up the SwaggerEndpoint with a relative path the the specification json, like you see below:

startup configuration

When I debug locally, everything resolves fine. But my site just runs as http://localhost:44348/index.html.

When I deploy to IIS, which is on a virtual path, it blows apart:

not resolving swagger.json

  1. Note that the URL in the browser has /imaging4castapi_UAT/ as part of the path
  2. Note that the actual request for the swagger.json is missing that base part of the path.

Here's what I've tried:

  1. I tried removing the RoutePrefix override. But that doesn't resolve.
  2. I tried using an application path like "~/swagger/..." but that's translated by the server on view elements like Razor pages and css and doesn't work here in Startup.

I'm struggling to understand if this is a client setup issue or something related to how my site is hosted on IIS.

Thoughts?

like image 853
Killnine Avatar asked Mar 01 '19 16:03

Killnine


1 Answers

Try using a relative path:

setupAction.SwaggerEndpoint("../swagger/Imaging4CastApiSpecification/swagger.json", "4Cast API");

Please note answer and explanation from the following issue: SwashBuckle

like image 80
eVolve Avatar answered Oct 13 '22 00:10

eVolve