Skip to content

Commit

Permalink
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.314.2
Browse files Browse the repository at this point in the history
  • Loading branch information
speakeasybot committed Jun 22, 2024
1 parent f02f220 commit 4dad78b
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 43 deletions.
10 changes: 5 additions & 5 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ id: 76b4d38c-5441-40d8-8002-c456a3ea1652
management:
docChecksum: 85248a8dd6a5cd6fea1b82dfc30249e9
docVersion: 1.0.0
speakeasyVersion: 1.313.0
generationVersion: 2.347.8
releaseVersion: 0.17.4
configChecksum: 35c6c096998276954844755a4be5a0e5
speakeasyVersion: 1.314.2
generationVersion: 2.349.6
releaseVersion: 0.17.5
configChecksum: bd4b62f4ad23e5fa766cbf429aabbe01
repoURL: https://github.com/ding-live/ding-csharp.git
repoSubDirectory: .
published: true
features:
csharp:
additionalDependencies: 0.1.0
core: 3.9.7
core: 3.9.8
examples: 2.81.3
flattening: 2.81.2
globalSecurity: 2.83.4
Expand Down
6 changes: 3 additions & 3 deletions DingSDK/Ding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public class Ding: IDing
public SDKConfig SDKConfiguration { get; private set; }

private const string _language = "csharp";
private const string _sdkVersion = "0.17.4";
private const string _sdkGenVersion = "2.347.8";
private const string _sdkVersion = "0.17.5";
private const string _sdkGenVersion = "2.349.6";
private const string _openapiDocVersion = "1.0.0";
private const string _userAgent = "speakeasy-sdk/csharp 0.17.4 2.347.8 1.0.0 DingSDK";
private const string _userAgent = "speakeasy-sdk/csharp 0.17.5 2.349.6 1.0.0 DingSDK";
private string _serverUrl = "";
private int _serverIndex = 0;
private ISpeakeasyHttpClient _client;
Expand Down
8 changes: 4 additions & 4 deletions DingSDK/DingSDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<PropertyGroup>
<IsPackable>true</IsPackable>
<PackageId>DingSDK</PackageId>
<Version>0.17.4</Version>
<Version>0.17.5</Version>
<Authors>Ding</Authors>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
<RepositoryUrl>https://github.com/ding-live/ding-csharp</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<None Include="..\NUGET.md" Pack="true" PackagePath="\README.md"/>
<None Include="..\LICENSE.md" Pack="true" PackagePath="\LICENSE.txt"/>
<None Include="..\NUGET.md" Pack="true" PackagePath="README.md"/>
<None Include="..\LICENSE.md" Pack="true" PackagePath="\"/>
<None Include="..\docs\**\*" Pack="true" PackagePath="\docs" CopyToOutputDirectory="PreserveNewest"/>

<PackageReference Include="newtonsoft.json" Version="13.0.3" />
Expand Down
6 changes: 3 additions & 3 deletions DingSDK/Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class Lookup: ILookup
{
public SDKConfig SDKConfiguration { get; private set; }
private const string _language = "csharp";
private const string _sdkVersion = "0.17.4";
private const string _sdkGenVersion = "2.347.8";
private const string _sdkVersion = "0.17.5";
private const string _sdkGenVersion = "2.349.6";
private const string _openapiDocVersion = "1.0.0";
private const string _userAgent = "speakeasy-sdk/csharp 0.17.4 2.347.8 1.0.0 DingSDK";
private const string _userAgent = "speakeasy-sdk/csharp 0.17.5 2.349.6 1.0.0 DingSDK";
private string _serverUrl = "";
private ISpeakeasyHttpClient _client;
private Func<Security>? _securitySource;
Expand Down
6 changes: 3 additions & 3 deletions DingSDK/Otp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public class Otp: IOtp
{
public SDKConfig SDKConfiguration { get; private set; }
private const string _language = "csharp";
private const string _sdkVersion = "0.17.4";
private const string _sdkGenVersion = "2.347.8";
private const string _sdkVersion = "0.17.5";
private const string _sdkGenVersion = "2.349.6";
private const string _openapiDocVersion = "1.0.0";
private const string _userAgent = "speakeasy-sdk/csharp 0.17.4 2.347.8 1.0.0 DingSDK";
private const string _userAgent = "speakeasy-sdk/csharp 0.17.5 2.349.6 1.0.0 DingSDK";
private string _serverUrl = "";
private ISpeakeasyHttpClient _client;
private Func<Security>? _securitySource;
Expand Down
93 changes: 93 additions & 0 deletions DingSDK/Utils/ResponseBodyDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ namespace DingSDK.Utils
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;


internal class ResponseBodyDeserializer
Expand All @@ -25,5 +27,96 @@ internal class ResponseBodyDeserializer
{
return JsonConvert.DeserializeObject<T>(json, new JsonSerializerSettings(){ NullValueHandling = nullValueHandling, MissingMemberHandling = missingMemberHandling, Converters = Utilities.GetJsonDeserializers(typeof(T))});
}

public sealed class MissingMemberException : Exception
{
public MissingMemberException() : base("Missing member.") { }
}

public sealed class DeserializationException : Exception
{
public DeserializationException(Type type) : base($"Could not deserialize into {type} type.") { }
}

public static T? DeserializeUndiscriminatedUnionMember<T>(string json)
{
try
{
return Deserialize<T>(json, missingMemberHandling: MissingMemberHandling.Error);
}
catch (Exception ex)
{
if (ex is Newtonsoft.Json.JsonSerializationException &&
ex.Source == "Newtonsoft.Json" &&
ex.Message.Contains("Could not find member"))
{
throw new MissingMemberException();
}
else if (ex is Newtonsoft.Json.JsonReaderException ||
ex is Newtonsoft.Json.JsonSerializationException
)
{
throw new DeserializationException(typeof(T));
}

throw;
}
}

public static object DeserializeUndiscriminatedUnionFallback(System.Type type, object obj, string propertyName, string json)
{
MethodInfo? method = typeof(ResponseBodyDeserializer).GetMethod("Deserialize");
if (method != null)
{
MethodInfo generic = method!.MakeGenericMethod(type);
var args = new object[] { json, NullValueHandling.Ignore, MissingMemberHandling.Ignore };
var value = generic.Invoke(null, args);
PropertyInfo? propertyInfo = obj.GetType().GetProperty(propertyName!);
if (propertyInfo != null && value != null)
{
propertyInfo!.SetValue(obj, value!);
return obj;
}
}

throw new DeserializationException(type);
}

public static int MissingJsonProperties(System.Type type, string json)
{
int missing = 0;

JObject jo = JObject.Parse(json);

var jsonPropertyAttributes = type.GetProperties()
.Where(prop => Attribute.IsDefined(prop, typeof(JsonPropertyAttribute)))
.Select(prop => prop.GetCustomAttribute(typeof(JsonPropertyAttribute)) as JsonPropertyAttribute)
.Where(attr => attr != null && attr!.PropertyName != null)
.ToList();

foreach (var attr in jsonPropertyAttributes)
{
string propertyName = attr!.PropertyName!;
if (!jo.TryGetValue(propertyName, out var _value)){
missing++;
}
}

return missing;
}

public static int CompareFallbackCandidates(System.Type typeA, System.Type typeB, string json)
{
var missingA = MissingJsonProperties(typeA, json);
var missingB = MissingJsonProperties(typeB, json);

if (missingA == missingB)
{
return typeB.GetProperties().Count().CompareTo(typeA.GetProperties().Count());
}

return missingA.CompareTo(missingB);
}

}
}
23 changes: 0 additions & 23 deletions NUGET.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# DingSDK

<div align="left">
<a href="https://speakeasyapi.dev/"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
</a>
</div>


<!-- Start Installation [installation] -->
## Installation

```bash
dotnet add package DingSDK
```
<!-- End Installation [installation] -->

<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage
Expand Down Expand Up @@ -90,14 +75,6 @@ var res = await sdk.Otp.RetryAsync(req);
```
<!-- End SDK Example Usage [usage] -->

<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations

- [Ding SDK](https:/github.com/ding-live/ding-csharp/blob/main/github/workspace/repo/docs/sdks/ding/README.md#available-operations)
- [Otp](https:/github.com/ding-live/ding-csharp/blob/main/github/workspace/repo/docs/sdks/otp/README.md#available-operations)
- [Lookup](https:/github.com/ding-live/ding-csharp/blob/main/github/workspace/repo/docs/sdks/lookup/README.md#available-operations)
<!-- End Available Resources and Operations [operations] -->

<!-- Start Error Handling [errors] -->
## Error Handling

Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,14 @@ Based on:
### Generated
- [csharp v0.17.4] .
### Releases
- [NuGet v0.17.4] https://www.nuget.org/packages/DingSDK/0.17.4 - .
- [NuGet v0.17.4] https://www.nuget.org/packages/DingSDK/0.17.4 - .

## 2024-06-22 00:17:30
### Changes
Based on:
- OpenAPI Doc 1.0.0
- Speakeasy CLI 1.314.2 (2.349.6) https://github.com/speakeasy-api/speakeasy
### Generated
- [csharp v0.17.5] .
### Releases
- [NuGet v0.17.5] https://www.nuget.org/packages/DingSDK/0.17.5 - .
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: false
csharp:
version: 0.17.4
version: 0.17.5
additionalDependencies: []
author: Ding
clientServerStatusCodesAsErrors: true
Expand Down

0 comments on commit 4dad78b

Please sign in to comment.