From afda4b4fd5690c99dc1629702968515524f79c62 Mon Sep 17 00:00:00 2001 From: hzhang Date: Thu, 1 May 2025 23:01:29 +0100 Subject: [PATCH] add: terminal tool --- Alchegos.Core.csproj | 4 + nswag.n8n.json | 101 +++++++++++++++++++++ src/Services/N8N/N8NApiClient.Extension.cs | 17 ++++ src/Services/N8N/N8NApiOptions.cs | 7 ++ 4 files changed, 129 insertions(+) create mode 100644 nswag.n8n.json create mode 100644 src/Services/N8N/N8NApiClient.Extension.cs create mode 100644 src/Services/N8N/N8NApiOptions.cs diff --git a/Alchegos.Core.csproj b/Alchegos.Core.csproj index 3ca0ff6..b01e3e7 100644 --- a/Alchegos.Core.csproj +++ b/Alchegos.Core.csproj @@ -4,6 +4,9 @@ net9.0 enable disable + true + 0.0.1 + Hangman @@ -19,5 +22,6 @@ + diff --git a/nswag.n8n.json b/nswag.n8n.json new file mode 100644 index 0000000..a7c4dba --- /dev/null +++ b/nswag.n8n.json @@ -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" + } + } +} \ No newline at end of file diff --git a/src/Services/N8N/N8NApiClient.Extension.cs b/src/Services/N8N/N8NApiClient.Extension.cs new file mode 100644 index 0000000..5bf48f5 --- /dev/null +++ b/src/Services/N8N/N8NApiClient.Extension.cs @@ -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 options) + { + _httpClient = client; + Options = options.Value; + BaseUrl = Options.BaseUrl; + _httpClient.DefaultRequestHeaders.Add("X-N8N-API-KEY", Options.Token); + } + +} \ No newline at end of file diff --git a/src/Services/N8N/N8NApiOptions.cs b/src/Services/N8N/N8NApiOptions.cs new file mode 100644 index 0000000..4224355 --- /dev/null +++ b/src/Services/N8N/N8NApiOptions.cs @@ -0,0 +1,7 @@ +namespace Alchegos.Core.Services.N8N; + +public class N8NApiOptions +{ + public string BaseUrl { get; set; } + public string Token { get; set; } +} \ No newline at end of file