since generating the swagger json on the fly takes around 3seconds locally (due to reflection in dotnet) I try to achieve the following:
This is what does not work:
var cdnPath = https://linktomycdn.com/staticswaggerstore
app.UseSwagger(c => c.SerializeAsV2 = true);
string swaggerUrl = $"{cdnPath}/swagger-{Version}.json";
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint(swaggerUrl, $"My API v{Version}");
options.OAuthClientId($"{config.ClientAuthConfig.JwtClientId}");
options.OAuthAppName($"{config.ClientAuthConfig.JwtClientApp}");
});
What happens is that the server correctly loads the json file (which I created with a swagger-cli tool) but then when I try to make calls with swagger-ui it uses the cdnpath as base. so that no call works.
Can I "split up" the swagger.json location and the actual endpoint?
I got it working by generating the json file with a specific --host flag
e.g.
dotnet swagger tofile --serializeasv2 --host mycoolapi.com --output .swagger-1.0.0.json /app/MyDll.dll v1.0.0
So now my API is using https://mycoolapi.com as host but the json sits on my CDN https://linktomycdn.com/staticswaggerstore. This is configured within the C# code as SwaggerEndpoint
Make sure to not provide the schema (https) in the --host parameter