4 Commits

Author SHA1 Message Date
06f60eec10 Generate api client with nswag 2025-01-22 08:55:37 -03:00
7275aef60b Update README.md 2025-01-22 08:53:47 -03:00
24c18dbbbe Update Tribufu.ComponentModel.csproj 2024-11-19 17:58:40 -03:00
7bb51a21e1 Add Tribufu.ComponentModel 2024-11-19 17:57:48 -03:00
17 changed files with 6111 additions and 48 deletions

13
Directory.Build.props Normal file
View File

@@ -0,0 +1,13 @@
<Project>
<PropertyGroup>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<FileVersion>1.0.0.0</FileVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
<Version>1.0.0</Version>
</PropertyGroup>
</Project>

View File

@@ -4,5 +4,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /> <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -6,7 +6,7 @@
[![Discord Chat][discord-badge]][discord-url] [![Discord Chat][discord-badge]][discord-url]
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg [mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: https://github.com/Tribufu/TribufuNet/blob/main/LICENSE.txt [mit-url]: https://github.com/tribufu/sdk-dotnet/blob/main/LICENSE.txt
[discord-badge]: https://img.shields.io/discord/276504514616623104.svg?logo=discord&style=flat-square [discord-badge]: https://img.shields.io/discord/276504514616623104.svg?logo=discord&style=flat-square
[discord-url]: https://www.tribufu.com/discord [discord-url]: https://www.tribufu.com/discord
@@ -17,4 +17,4 @@
This project is licensed under the [MIT License]. This project is licensed under the [MIT License].
[MIT License]: https://github.com/Tribufu/TribufuNet/blob/main/LICENSE.txt [MIT License]: https://github.com/tribufu/sdk-dotnet/blob/main/LICENSE.txt

View File

@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu", "src\Tribufu\Trib
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Utils", "src\Tribufu.Utils\Tribufu.Utils.csproj", "{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Utils", "src\Tribufu.Utils\Tribufu.Utils.csproj", "{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.ComponentModel", "src\Tribufu.ComponentModel\Tribufu.ComponentModel.csproj", "{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -37,6 +39,10 @@ Global
{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}.Release|Any CPU.ActiveCfg = Release|Any CPU {8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}.Release|Any CPU.Build.0 = Release|Any CPU {8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}.Release|Any CPU.Build.0 = Release|Any CPU
{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

3
scripts/nswag.ps1 Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env sh
nswag run ./src/Tribufu/api.nswag

View File

@@ -0,0 +1,30 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
using System;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace Tribufu.ComponentModel
{
public class EnumMemberConverter<T> : EnumConverter
{
public EnumMemberConverter(Type type) : base(type) { }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var type = typeof(T);
foreach (var field in type.GetFields())
{
if (Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)) is EnumMemberAttribute attribute && value is string enumValue && attribute.Value == enumValue)
{
return field.GetValue(null);
}
}
return base.ConvertFrom(context, culture, value);
}
}
}

View File

@@ -0,0 +1 @@
# Tribufu

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.ComponentModel</PackageId>
<Description>Tribufu Component Model Helpers</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

View File

@@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<PackageId>Tribufu.Native</PackageId> <PackageId>Tribufu.Native</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Native Interop</Description> <Description>Tribufu Native Interop</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
@@ -17,12 +10,12 @@
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\vendor\win-arm64\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-arm64\native\" /> <None Include="..\..\vendor\win-arm64\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-arm64\native\" />
<None Include="..\..\vendor\win-x64\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-x64\native\" /> <None Include="..\..\vendor\win-x64\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-x64\native\" />
<None Include="..\..\vendor\win-x86\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-x86\native\" /> <None Include="..\..\vendor\win-x86\tribufu_sdk.dll" Pack="true" PackagePath="runtimes\win-x86\native\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<PackageId>Tribufu.Serialization.Newtonsoft</PackageId> <PackageId>Tribufu.Serialization.Newtonsoft</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Serialization Helpers for Newtonsoft.Json</Description> <Description>Tribufu Serialization Helpers for Newtonsoft.Json</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
@@ -17,10 +10,10 @@
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" /> <None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<PackageId>Tribufu.Serialization</PackageId> <PackageId>Tribufu.Serialization</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Serialization Helpers</Description> <Description>Tribufu Serialization Helpers</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>

View File

@@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<PackageId>Tribufu.Utils</PackageId> <PackageId>Tribufu.Utils</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu Utils</Description> <Description>Tribufu Utils</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
@@ -17,9 +10,9 @@
<TargetFrameworks>net5.0</TargetFrameworks> <TargetFrameworks>net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" /> <None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
</ItemGroup>
</Project> </Project>

View File

@@ -1,15 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<PackageId>Tribufu</PackageId> <PackageId>Tribufu</PackageId>
<Version>0.1.0</Version>
<Description>Tribufu .NET SDK</Description> <Description>Tribufu .NET SDK</Description>
<Authors>Tribufu</Authors>
<Company>Tribufu</Company>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Tribufu. All Rights Reserved.</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Tribufu/TribufuNet</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
@@ -17,10 +10,15 @@
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Tribufu.Native\Tribufu.Native.csproj" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" /> <None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.ComponentModel.Annotations" />
<PackageReference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tribufu.Native\Tribufu.Native.csproj" />
</ItemGroup>
</Project> </Project>

14
src/Tribufu/TribufuApi.cs Normal file
View 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())
{
}
}
}

File diff suppressed because it is too large Load Diff

View 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
View 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"
}
}
}