I used NSwag to generate Api documents. my website protocol is https, but NSwag still uses http

The scheme is set to the one from the request:
https://github.com/RSuter/NSwag/blob/master/src/NSwag.AspNetCore/Middlewares/AspNetCoreToSwaggerMiddleware.cs#L96
You can change this in a PostProcess action or document processor (settings).
NSwag v12 app.AddSwaggerDocument(configure => configure.PostProcess = (document) => document.Schemes = new[] { SwaggerSchema.Https });
Please post process in AddSwaggerDocument and not in UseSwagger, I've updated your comment
@RicoSuter I've tried with PostProcess in AddSwaggerDocument and it did nothing. Only when I switched to:
app.UseOpenApi(a => {
a.PostProcess = (document, _) => {
document.Schemes = new[] { OpenApiSchema.Https, OpenApiSchema.Http };
};
});
Did I get this to work. What's the difference?
Change this in UseSwagger() or UseOpenApi..
@RicoSuter I'm asking because in previous comment (https://github.com/RicoSuter/NSwag/issues/1545#issuecomment-444098812) you are saying:
Please post process in AddSwaggerDocument and not in UseSwagger
So I was just wondering on rational/why behind it back then. Thanks!
When running via cli then only AddSwaggerDocument is called, when starting as regular asp app both are called and the url/https stuff is overwritten in the use() call with the actual endpoint info and thus this has to be changed there. The document itself (except endpoint info) should be changed in add()
Most helpful comment
The scheme is set to the one from the request:
https://github.com/RSuter/NSwag/blob/master/src/NSwag.AspNetCore/Middlewares/AspNetCoreToSwaggerMiddleware.cs#L96
You can change this in a PostProcess action or document processor (settings).