add: terminal tool

This commit is contained in:
h z
2025-05-01 23:01:29 +01:00
parent e94a27823c
commit afda4b4fd5
4 changed files with 129 additions and 0 deletions

View File

@@ -4,6 +4,9 @@
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.1</Version>
<Authors>Hangman</Authors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -19,5 +22,6 @@
<Target Name="GenerateNSwagClient" BeforeTargets="BeforeBuild"> <Target Name="GenerateNSwagClient" BeforeTargets="BeforeBuild">
<Exec Command="$(NSwagExe_Net80) run nswag.gitea.json" /> <Exec Command="$(NSwagExe_Net80) run nswag.gitea.json" />
<Exec Command="$(NSwagExe_Net80) run nswag.youtrack.json" /> <Exec Command="$(NSwagExe_Net80) run nswag.youtrack.json" />
<Exec Command="$(NSwagExe_Net80) run nswag.n8n.json" />
</Target> </Target>
</Project> </Project>

101
nswag.n8n.json Normal file
View File

@@ -0,0 +1,101 @@
{
"runtime": "Net80",
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"url": "http://localhost:5678/api/v1/openapi.yml",
"output": null,
"newLineBehavior": "Auto"
}
},
"codeGenerators": {
"openApiToCSharpClient": {
"clientBaseClass": null,
"configurationClass": null,
"generateClientClasses": true,
"suppressClientClassesOutput": false,
"generateClientInterfaces": false,
"suppressClientInterfacesOutput": false,
"clientBaseInterface": null,
"injectHttpClient": true,
"disposeHttpClient": true,
"protectedMethods": [],
"generateExceptionClasses": true,
"exceptionClass": "ApiException",
"wrapDtoExceptions": true,
"useHttpClientCreationMethod": false,
"httpClientType": "System.Net.Http.HttpClient",
"useHttpRequestMessageCreationMethod": false,
"useBaseUrl": true,
"generateBaseUrlProperty": true,
"generateSyncMethods": false,
"generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
"exposeJsonSerializerSettings": false,
"clientClassAccessModifier": "public",
"typeAccessModifier": "public",
"propertySetterAccessModifier": "",
"generateNativeRecords": false,
"generateContractsOutput": false,
"contractsNamespace": null,
"contractsOutputFilePath": null,
"parameterDateTimeFormat": "s",
"parameterDateFormat": "yyyy-MM-dd",
"generateUpdateJsonSerializerSettingsMethod": true,
"useRequestAndResponseSerializationSettings": false,
"serializeTypeInformation": false,
"queryNullValue": "",
"className": "N8NApiClient",
"operationGenerationMode": "MultipleClientsFromOperationId",
"additionalNamespaceUsages": [],
"additionalContractNamespaceUsages": [],
"generateOptionalParameters": false,
"generateJsonMethods": false,
"enforceFlagEnums": false,
"parameterArrayType": "System.Collections.Generic.IEnumerable",
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
"responseArrayType": "System.Collections.Generic.ICollection",
"responseDictionaryType": "System.Collections.Generic.IDictionary",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"namespace": "Alchegos.Core.Services.N8N",
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTimeOffset",
"jsonConverters": null,
"anyType": "object",
"dateTimeType": "System.DateTimeOffset",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.ICollection",
"arrayInstanceType": "System.Collections.ObjectModel.Collection",
"dictionaryType": "System.Collections.Generic.IDictionary",
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
"arrayBaseType": "System.Collections.ObjectModel.Collection",
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
"classStyle": "Poco",
"jsonLibrary": "NewtonsoftJson",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"jsonSerializerSettingsTransformationMethod": null,
"inlineNamedArrays": false,
"inlineNamedDictionaries": false,
"inlineNamedTuples": true,
"inlineNamedAny": false,
"generateDtoTypes": true,
"generateOptionalPropertiesAsNullable": false,
"generateNullableReferenceTypes": false,
"templateDirectory": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "src/Services/N8N/N8NApiClient.cs",
"newLineBehavior": "Auto"
}
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.Extensions.Options;
namespace Alchegos.Core.Services.N8N;
public partial class N8NApiClient
{
private N8NApiOptions Options { get; set; }
public N8NApiClient(HttpClient client, IOptions<N8NApiOptions> options)
{
_httpClient = client;
Options = options.Value;
BaseUrl = Options.BaseUrl;
_httpClient.DefaultRequestHeaders.Add("X-N8N-API-KEY", Options.Token);
}
}

View File

@@ -0,0 +1,7 @@
namespace Alchegos.Core.Services.N8N;
public class N8NApiOptions
{
public string BaseUrl { get; set; }
public string Token { get; set; }
}