mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
swagger specs for public api
This commit is contained in:
@ -14,6 +14,7 @@ using Stripe;
|
||||
using Bit.Core.Utilities;
|
||||
using IdentityModel;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
|
||||
namespace Bit.Api
|
||||
{
|
||||
@ -110,10 +111,13 @@ namespace Bit.Api
|
||||
// MVC
|
||||
services.AddMvc(config =>
|
||||
{
|
||||
config.Conventions.Add(new ApiExplorerGroupConvention());
|
||||
config.Filters.Add(new ExceptionHandlerFilterAttribute());
|
||||
config.Filters.Add(new ModelStateValidationFilterAttribute());
|
||||
}).AddJsonOptions(o => o.SerializerSettings.ContractResolver = new DefaultContractResolver());
|
||||
|
||||
services.AddSwagger(globalSettings);
|
||||
|
||||
if(globalSettings.SelfHosted)
|
||||
{
|
||||
// Jobs service
|
||||
@ -182,6 +186,21 @@ namespace Bit.Api
|
||||
|
||||
// Add MVC to the request pipeline.
|
||||
app.UseMvc();
|
||||
|
||||
if(globalSettings.SelfHosted)
|
||||
{
|
||||
app.UseSwagger(config =>
|
||||
{
|
||||
config.RouteTemplate = "specs/{documentName}/swagger.json";
|
||||
});
|
||||
app.UseSwaggerUI(config =>
|
||||
{
|
||||
config.RoutePrefix = "docs";
|
||||
config.SwaggerEndpoint("/specs/public/swagger.json", "Bitwarden Public API");
|
||||
config.OAuthClientId("accountType.id");
|
||||
config.OAuthClientSecret("secretKey");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user