Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Is there a way to specify specific OpenApiServer's for each individual path?
I'm trying trying to create a merged swagger json out of various microservices that we have, as per the suggestions in #2043 but have found a bit of a stumbling block when it comes to associating specific servers with paths.
For each service, when setting up swagger gen, I can specify the server to use like so:
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "xxx", Description = "xxx", Version = "v1" });
options.DescribeAllParametersInCamelCase();
options.IgnoreObsoleteActions();
options.AddSecurityDefinition("firebase", new OpenApiSecurityScheme
{
Name = HeaderNames.Authorization,
Scheme = "bearer",
BearerFormat = "JWT",
Type = SecuritySchemeType.Http,
In = ParameterLocation.Header,
Description = "A bearer token returned via the Firebase login action to access any endpoint documented here."
});
options.AddServer(new OpenApiServer { Url = environmentUrl });
});
However, this only adds a server to the main Servers
list for the generated document. I can see that when I deserialize the json into an OpenApiDocument, the various deserialized Paths have a property for Servers, so as a hack I am taking the main doc server and copying that into the Path server after deserialization, but it would be ideal if I could associate that server with the paths on the swagger gen side of things.
Is there a way to do this that I am missing? Or does that functionality not exist?