mirror of
https://github.com/tribufu/tribufu-dotnet
synced 2025-06-15 18:04:18 +00:00
Generate api client with nswag
This commit is contained in:
3
scripts/nswag.ps1
Normal file
3
scripts/nswag.ps1
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
nswag run ./src/Tribufu/api.nswag
|
14
src/Tribufu/TribufuApi.cs
Normal file
14
src/Tribufu/TribufuApi.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (c) Tribufu. All Rights Reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace Tribufu
|
||||||
|
{
|
||||||
|
public class TribufuApi : TribufuApiGenerated
|
||||||
|
{
|
||||||
|
public TribufuApi(TribufuApiOptions options) : base(options.BaseUrl, new HttpClient())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5889
src/Tribufu/TribufuApi.generated.cs
Normal file
5889
src/Tribufu/TribufuApi.generated.cs
Normal file
File diff suppressed because it is too large
Load Diff
18
src/Tribufu/TribufuApiOptions.cs
Normal file
18
src/Tribufu/TribufuApiOptions.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (c) Tribufu. All Rights Reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
namespace Tribufu
|
||||||
|
{
|
||||||
|
public class TribufuApiOptions
|
||||||
|
{
|
||||||
|
public string BaseUrl { get; set; }
|
||||||
|
|
||||||
|
public string ApiKey { get; set; }
|
||||||
|
|
||||||
|
public TribufuApiOptions(string baseUrl, string apiKey)
|
||||||
|
{
|
||||||
|
BaseUrl = baseUrl;
|
||||||
|
ApiKey = apiKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
101
src/Tribufu/api.nswag
Normal file
101
src/Tribufu/api.nswag
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
{
|
||||||
|
"runtime": "Default",
|
||||||
|
"defaultVariables": null,
|
||||||
|
"documentGenerator": {
|
||||||
|
"fromDocument": {
|
||||||
|
"json": "",
|
||||||
|
"url": "https://api.tribufu.com/v1/openapi.json",
|
||||||
|
"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": "TribufuApiException",
|
||||||
|
"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": "TribufuApiGenerated",
|
||||||
|
"operationGenerationMode": "SingleClientFromOperationId",
|
||||||
|
"additionalNamespaceUsages": [],
|
||||||
|
"additionalContractNamespaceUsages": [],
|
||||||
|
"generateOptionalParameters": true,
|
||||||
|
"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": "Tribufu",
|
||||||
|
"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": "TribufuApi.generated.cs",
|
||||||
|
"newLineBehavior": "LF"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user