Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 for 'swagger.json' when running in IIS #1914

Open
rverberne opened this issue Jan 24, 2019 · 1 comment
Open

404 for 'swagger.json' when running in IIS #1914

rverberne opened this issue Jan 24, 2019 · 1 comment

Comments

@rverberne
Copy link

rverberne commented Jan 24, 2019

In IIS there is a site: localhost:4444
This site has multiple applications, one ASP.Net core, with Kestrel, not in process. Application has name webapp.

Swagger UI is visible at localhost:4444/webapp/swagger/index.html.
Now from browser request is made to localhost:4444/swagger/v1/swagger.json and gives 404.
Other files (CSS, javascript, favicon) all work.

Is this a bug? I am trying to fix it with TransformToExternalPath lambda.

@rverberne
Copy link
Author

rverberne commented Jan 24, 2019

Fix:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
	app.UseSwaggerUi3(config =>
	{
		config.TransformToExternalPath = (s, r) =>
		{
			string path = s.EndsWith("swagger.json") && !string.IsNullOrEmpty(r.PathBase)
				? $"{r.PathBase}{s}"
				: s;
			return path;
		};
		config.TagsSorter = "alpha";
		config.OperationsSorter = "alpha";
		config.EnableTryItOut = false;
	});
}

But should this be necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants