Merge pull request #58 from sbwalker/master

Added Swagger support for API
This commit is contained in:
Shaun Walker 2019-08-16 11:36:13 -04:00 committed by GitHub
commit 7558e3eb35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -43,6 +43,7 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview8.19405.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview8.19405.11" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
</ItemGroup>
<ItemGroup>

View File

@ -20,6 +20,7 @@ using Oqtane.Shared;
using Microsoft.AspNetCore.Identity;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.OpenApi.Models;
namespace Oqtane.Server
{
@ -179,6 +180,11 @@ namespace Oqtane.Server
}
}
}
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Oqtane", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -202,6 +208,12 @@ namespace Oqtane.Server
app.UseAuthentication();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Oqtane V1");
});
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
@ -317,6 +329,11 @@ namespace Oqtane.Server
}
}
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Oqtane", Version = "v1" });
});
services.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
@ -341,6 +358,12 @@ namespace Oqtane.Server
app.UseAuthentication();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Oqtane V1");
});
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();