Skip to content

Commit

Permalink
Sample App Bug fixed
Browse files Browse the repository at this point in the history
Ref: #6
Update to .NET Core 3.1 from 3.0
Update Swagger Package to latest version
  • Loading branch information
a-patel committed Oct 21, 2020
1 parent 59f6b87 commit 5d52879
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 46 deletions.
40 changes: 9 additions & 31 deletions sample/LiteXCache.Demo/Extensions/SwaggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#region Imports
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.Examples;
using Swashbuckle.AspNetCore.Swagger;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerUI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
#endregion
Expand All @@ -26,49 +24,29 @@ public static IServiceCollection AddLiteXCacheSwagger(this IServiceCollection se
{
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v8", new Info
options.SwaggerDoc("v8", new OpenApiInfo
{
Version = "v8",
Title = "LiteX Cache",
Description = "LiteX Cache (InMemory, Redis, Memcached, SQLite)",
TermsOfService = "None",
Contact = new Contact() { Name = "Aashish Patel", Email = "toaashishpatel@outlook.com", Url = "https://aashishpatel.netlify.com/" },
License = new License() { Name = "LiteX LICENSE", Url = "https://github.com/a-patel/LiteXCache/blob/master/LICENSE" }
TermsOfService = new Uri("https://github.com/a-patel/LiteXCache/blob/master/LICENSE"),
Contact = new OpenApiContact() { Name = "Ashish Patel", Email = "toaashishpatel@gmail.com", Url = new Uri("https://aashishpatel.netlify.app/") },
License = new OpenApiLicense() { Name = "LICENSE", Url = new Uri("https://github.com/a-patel/LiteXCache/blob/master/LICENSE") }
});
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
options.IncludeXmlComments(xmlPath);
//var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, $"LiteXCache.Demo.xml");
//options.IncludeXmlComments(filePath);
////options.IncludeXmlComments(GetXmlCommentsPath());
//// Set the comments path for the Swagger JSON and UI. For all libraries
//var xmlFiles = Directory.GetFiles(AppContext.BaseDirectory, "*.xml", SearchOption.TopDirectoryOnly).ToList();
//xmlFiles.ForEach(xmlFile => options.IncludeXmlComments(xmlFile));
options.DescribeAllEnumsAsStrings();
options.IgnoreObsoleteProperties();
options.IgnoreObsoleteActions();
options.OperationFilter<AddFileParamTypesOperationFilter>(); //Register File Upload Operation Filter
#region Authorization
// Swagger 2.+ support
var security = new Dictionary<string, IEnumerable<string>>
{
{"Bearer", new string[] { }},
};
options.AddSecurityDefinition("Bearer", new ApiKeyScheme
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
options.AddSecurityRequirement(security);
#endregion
});


Expand Down
23 changes: 12 additions & 11 deletions sample/LiteXCache.Demo/LiteXCache.Demo.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.0\LiteXCache.Demo.xml</DocumentationFile>
</PropertyGroup>
<!--<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp3.1\LiteXCache.Demo.xml</DocumentationFile>
</PropertyGroup>-->

<PropertyGroup>
<NoWarn>1701;1702;1705;CS1591</NoWarn>
Expand All @@ -25,13 +25,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LiteX.Cache" Version="8.0.0" />
<PackageReference Include="LiteX.Cache.Core" Version="8.0.0" />
<PackageReference Include="LiteX.Cache.Memcached" Version="8.0.0" />
<PackageReference Include="LiteX.Cache.Redis" Version="8.0.0" />
<PackageReference Include="LiteX.Cache.SQLite" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Examples" Version="2.9.0" />
<PackageReference Include="LiteX.Cache" Version="8.1.0" />
<PackageReference Include="LiteX.Cache.Core" Version="8.1.0" />
<PackageReference Include="LiteX.Cache.Memcached" Version="8.1.0" />
<PackageReference Include="LiteX.Cache.Redis" Version="8.1.0" />
<PackageReference Include="LiteX.Cache.SQLite" Version="8.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.6.3" />
<PackageReference Include="LiteX.Extensions.Logging" Version="2.0.0" />
</ItemGroup>

Expand Down
10 changes: 6 additions & 4 deletions sample/LiteXCache.Demo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public void ConfigureServices(IServiceCollection services)

services.AddLiteXLogging();

services.AddHttpContextAccessor();

services.AddControllers();
}

Expand All @@ -201,11 +203,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

#region LiteX Caching

//Memcached
app.UseLiteXMemcachedCache();
////Memcached
//app.UseLiteXMemcachedCache();

//SQLite
app.UseLiteXSQLiteCache();
////SQLite
//app.UseLiteXSQLiteCache();

#endregion

Expand Down

0 comments on commit 5d52879

Please sign in to comment.