增加功能:增加web api versioning组件
This commit is contained in:
parent
bbed98b4ae
commit
f78f6970e2
|
@ -8,7 +8,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DocumentationFile>Z:\src\Longbow\BootstrapAdmin\Bootstrap.Admin\Bootstrap.Admin.xml</DocumentationFile>
|
<DocumentationFile>..\Bootstrap.Admin\Bootstrap.Admin.xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
<PackageReference Include="Longbow.Logging" Version="1.0.2" />
|
<PackageReference Include="Longbow.Logging" Version="1.0.2" />
|
||||||
<PackageReference Include="Longbow.Web" Version="1.0.1" />
|
<PackageReference Include="Longbow.Web" Version="1.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -15,6 +15,7 @@ using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Versioning;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -79,6 +80,13 @@ namespace Bootstrap.Admin
|
||||||
JsonConvert.DefaultSettings = () => options.SerializerSettings;
|
JsonConvert.DefaultSettings = () => options.SerializerSettings;
|
||||||
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||||
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.Cookie.Path = "/");
|
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.Cookie.Path = "/");
|
||||||
|
services.AddApiVersioning(option =>
|
||||||
|
{
|
||||||
|
option.DefaultApiVersion = new ApiVersion(1, 0);
|
||||||
|
option.ReportApiVersions = true;
|
||||||
|
option.AssumeDefaultVersionWhenUnspecified = true;
|
||||||
|
option.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("api-version"), new QueryStringApiVersionReader("api-version"));
|
||||||
|
});
|
||||||
services.AddSwaggerGen(options =>
|
services.AddSwaggerGen(options =>
|
||||||
{
|
{
|
||||||
options.SwaggerDoc("v1", new Info
|
options.SwaggerDoc("v1", new Info
|
||||||
|
|
Loading…
Reference in New Issue