mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Add support for Newtonsoft.Json to Swagger
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
<PackageReference Include="protobuf-net" Version="3.0.0-alpha.43" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc5" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc5" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.0.0-rc5" />
|
||||
<PackageReference Include="System.Composition" Version="1.4.0" />
|
||||
<Reference Include="SteamKit2">
|
||||
<HintPath>lib\SteamKit2.dll</HintPath>
|
||||
|
||||
@@ -35,6 +35,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace ArchiSteamFarm.IPC {
|
||||
@@ -108,7 +109,14 @@ namespace ArchiSteamFarm.IPC {
|
||||
app.UseSwagger();
|
||||
|
||||
// Use friendly swagger UI
|
||||
app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/" + SharedInfo.ASF + "/swagger.json", SharedInfo.ASF + " API"));
|
||||
app.UseSwaggerUI(
|
||||
options => {
|
||||
options.DisplayRequestDuration();
|
||||
options.EnableDeepLinking();
|
||||
options.ShowExtensions();
|
||||
options.SwaggerEndpoint("/swagger/" + SharedInfo.ASF + "/swagger.json", SharedInfo.ASF + " API");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services) {
|
||||
@@ -156,7 +164,7 @@ namespace ArchiSteamFarm.IPC {
|
||||
}
|
||||
);
|
||||
|
||||
options.EnableAnnotations();
|
||||
options.EnableAnnotations(true);
|
||||
|
||||
options.SwaggerDoc(
|
||||
SharedInfo.ASF, new OpenApiInfo {
|
||||
@@ -182,6 +190,9 @@ namespace ArchiSteamFarm.IPC {
|
||||
}
|
||||
);
|
||||
|
||||
// Add Newtonsoft.Json support for SwaggerGen, this one must be executed after AddSwaggerGen()
|
||||
services.AddSwaggerGenNewtonsoftSupport();
|
||||
|
||||
// We need MVC for /Api, but we're going to use only a small subset of all available features
|
||||
#if NETFRAMEWORK
|
||||
IMvcCoreBuilder mvc = services.AddMvcCore();
|
||||
@@ -220,6 +231,7 @@ namespace ArchiSteamFarm.IPC {
|
||||
#endif
|
||||
options => {
|
||||
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||
options.SerializerSettings.Converters.Add(new StringEnumConverter());
|
||||
|
||||
if (Debugging.IsUserDebugging) {
|
||||
options.SerializerSettings.Formatting = Formatting.Indented;
|
||||
|
||||
Reference in New Issue
Block a user