Add nswag
This commit is contained in:
parent
207767dbce
commit
01efc3b8b8
4 changed files with 120 additions and 1 deletions
|
|
@ -6,7 +6,15 @@
|
||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"commands": [
|
"commands": [
|
||||||
"dotnet-ef"
|
"dotnet-ef"
|
||||||
]
|
],
|
||||||
|
"rollForward": false
|
||||||
|
},
|
||||||
|
"nswag.consolecore": {
|
||||||
|
"version": "14.2.0",
|
||||||
|
"commands": [
|
||||||
|
"nswag"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.Hosting.WindowsServices;
|
using Microsoft.Extensions.Hosting.WindowsServices;
|
||||||
|
using NSwag;
|
||||||
using RdtClient.Data.Data;
|
using RdtClient.Data.Data;
|
||||||
using RdtClient.Data.Models.Internal;
|
using RdtClient.Data.Models.Internal;
|
||||||
using RdtClient.Service;
|
using RdtClient.Service;
|
||||||
|
|
@ -25,6 +27,30 @@ var appSettings = new AppSettings();
|
||||||
builder.Configuration.Bind(appSettings);
|
builder.Configuration.Bind(appSettings);
|
||||||
builder.Services.AddSingleton(appSettings);
|
builder.Services.AddSingleton(appSettings);
|
||||||
|
|
||||||
|
// Add services for client generation
|
||||||
|
builder.Services.AddOpenApiDocument(options => {
|
||||||
|
options.PostProcess = document =>
|
||||||
|
{
|
||||||
|
document.Info = new OpenApiInfo
|
||||||
|
{
|
||||||
|
Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString(),
|
||||||
|
Title = "RdtClient API",
|
||||||
|
Description = "A web interface to manage your torrents on a Debrid provider.",
|
||||||
|
License = new OpenApiLicense
|
||||||
|
{
|
||||||
|
Name = "MIT",
|
||||||
|
Url = "https://github.com/rogerfar/rdt-client/blob/master/LICENSE"
|
||||||
|
},
|
||||||
|
Contact = new OpenApiContact()
|
||||||
|
{
|
||||||
|
Name = "Source Code",
|
||||||
|
Url = "https://github.com/rogerfar/rdt-client",
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// Configure URLs
|
// Configure URLs
|
||||||
if (appSettings.Port <= 0)
|
if (appSettings.Port <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -38,6 +39,7 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.2" />
|
||||||
|
<PackageReference Include="NSwag.AspNetCore" Version="14.2.0" />
|
||||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
|
|
|
||||||
83
server/RdtClient.Web/nswag.json
Normal file
83
server/RdtClient.Web/nswag.json
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
{
|
||||||
|
"runtime": "Net90",
|
||||||
|
"defaultVariables": null,
|
||||||
|
"documentGenerator": {
|
||||||
|
"aspNetCoreToOpenApi": {
|
||||||
|
"project": "RdtClient.Web.csproj",
|
||||||
|
"documentName": "v1",
|
||||||
|
"msBuildProjectExtensionsPath": null,
|
||||||
|
"configuration": null,
|
||||||
|
"runtime": null,
|
||||||
|
"targetFramework": null,
|
||||||
|
"noBuild": false,
|
||||||
|
"msBuildOutputPath": null,
|
||||||
|
"verbose": true,
|
||||||
|
"workingDirectory": null,
|
||||||
|
"aspNetCoreEnvironment": null,
|
||||||
|
"output": "openapi.json",
|
||||||
|
"newLineBehavior": "Auto"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codeGenerators": {
|
||||||
|
"openApiToTypeScriptClient": {
|
||||||
|
"className": "{controller}Client",
|
||||||
|
"moduleName": "",
|
||||||
|
"namespace": "",
|
||||||
|
"typeScriptVersion": 5.0,
|
||||||
|
"template": "Fetch",
|
||||||
|
"promiseType": "Promise",
|
||||||
|
"httpClass": "HttpClient",
|
||||||
|
"withCredentials": false,
|
||||||
|
"useSingletonProvider": false,
|
||||||
|
"injectionTokenType": "OpaqueToken",
|
||||||
|
"rxJsVersion": 6.0,
|
||||||
|
"dateTimeType": "Date",
|
||||||
|
"nullValue": "Undefined",
|
||||||
|
"generateClientClasses": true,
|
||||||
|
"generateClientInterfaces": false,
|
||||||
|
"generateOptionalParameters": false,
|
||||||
|
"exportTypes": true,
|
||||||
|
"wrapDtoExceptions": false,
|
||||||
|
"exceptionClass": "ApiException",
|
||||||
|
"clientBaseClass": null,
|
||||||
|
"wrapResponses": false,
|
||||||
|
"wrapResponseMethods": [],
|
||||||
|
"generateResponseClasses": true,
|
||||||
|
"responseClass": "SwaggerResponse",
|
||||||
|
"protectedMethods": [],
|
||||||
|
"configurationClass": null,
|
||||||
|
"useTransformOptionsMethod": false,
|
||||||
|
"useTransformResultMethod": false,
|
||||||
|
"generateDtoTypes": true,
|
||||||
|
"operationGenerationMode": "MultipleClientsFromOperationId",
|
||||||
|
"markOptionalProperties": true,
|
||||||
|
"generateCloneMethod": false,
|
||||||
|
"typeStyle": "Class",
|
||||||
|
"enumStyle": "Enum",
|
||||||
|
"useLeafType": false,
|
||||||
|
"classTypes": [],
|
||||||
|
"extendedClasses": [],
|
||||||
|
"extensionCode": null,
|
||||||
|
"generateDefaultValues": true,
|
||||||
|
"excludedTypeNames": [],
|
||||||
|
"excludedParameterNames": [],
|
||||||
|
"handleReferences": false,
|
||||||
|
"generateTypeCheckFunctions": false,
|
||||||
|
"generateConstructorInterface": true,
|
||||||
|
"convertConstructorInterfaceData": false,
|
||||||
|
"importRequiredTypes": true,
|
||||||
|
"useGetBaseUrlMethod": false,
|
||||||
|
"baseUrlTokenName": "API_BASE_URL",
|
||||||
|
"queryNullValue": "",
|
||||||
|
"useAbortSignal": false,
|
||||||
|
"inlineNamedDictionaries": false,
|
||||||
|
"inlineNamedAny": false,
|
||||||
|
"includeHttpContext": false,
|
||||||
|
"templateDirectory": null,
|
||||||
|
"serviceHost": null,
|
||||||
|
"serviceSchemes": null,
|
||||||
|
"output": "../../client/src/app/apiClient.ts",
|
||||||
|
"newLineBehavior": "Auto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue