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

Observe the route prefix in RestierSwaggerProvider #755

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ public OpenApiDocument GetSwagger(string documentName, string host = null, strin
openApiSettings?.Invoke(settings);

// @robertmclaws: The host defaults internally to localhost; isn't set automatically.
var requestHost = httpContextAccessor.HttpContext.Request.Host.Value;
if (!settings.ServiceRoot.ToString().StartsWith(requestHost))
{
settings.ServiceRoot = new Uri($"{httpContextAccessor.HttpContext.Request.Scheme}://{requestHost}");
}
var request = httpContextAccessor.HttpContext?.Request ?? throw new InvalidOperationException("The HttpContext is not available");
var routePrefix = perRouteContainer.GetRoutePrefix(documentName);
var path = string.IsNullOrEmpty(routePrefix) ? "" : $"{routePrefix}/";
settings.ServiceRoot = new Uri($"{request.Scheme}://{request.Host}/{path}");

return model.ConvertToOpenApi(settings);
}
Expand Down