1
0
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:
Kyle Spearrin
2019-02-28 14:20:14 -05:00
parent b6696df055
commit 1c71af47bb
4 changed files with 72 additions and 0 deletions

View File

@ -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");
});
}
}
}
}