Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 🐝 Update SDK - Generate #6

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ id: f1a8c321-72a7-41c5-8f5e-3d925aeafa1a
management:
docChecksum: 2401c7030f847f72ab31c8f75de58a66
docVersion: 0.2.0
speakeasyVersion: 1.213.0
generationVersion: 2.283.1
releaseVersion: 0.1.0
configChecksum: ef8305e66f6c0da55e15a2c60e06f357
speakeasyVersion: 1.227.0
generationVersion: 2.291.0
releaseVersion: 0.1.1
configChecksum: cf7f772784da84b4987084bd63356eed
repoURL: https://github.com/StyraInc/opa-csharp.git
features:
csharp:
core: 3.4.3
examples: 2.81.3
flattening: 2.81.1
globalServerURLs: 2.82.3
unions: 0.0.1
unions: 0.0.2
generatedFiles:
- Api/Opa.cs
- global.json
- Api/Utils/BigIntSerializer.cs
- Api/Utils/DecimalSerializer.cs
- Api/Utils/EnumSerializer.cs
- Api/Utils/AnyDeserializer.cs
- Api/Utils/BigIntStrConverter.cs
- Api/Utils/DecimalStrConverter.cs
- Api/Utils/EnumConverter.cs
- Api/Utils/FlexibleObjectDeserializer.cs
- Api/Utils/HeaderSerializer.cs
- Api/Utils/IsoDateTimeSerializer.cs
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: false
csharp:
version: 0.1.0
version: 0.1.1
author: Styra
dotnetVersion: net6.0
flattenGlobalSecurity: true
Expand Down
2 changes: 1 addition & 1 deletion Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsPackable>true</IsPackable>
<PackageId>api</PackageId>
<Version>0.1.0</Version>
<Version>0.1.1</Version>
<Authors>Styra</Authors>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
Expand Down
9 changes: 4 additions & 5 deletions Api/Models/Components/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class InputType

public static InputType Number { get { return new InputType("number"); } }

public static InputType Null { get { return new InputType("null"); } }
public static InputType Null { get { return new InputType("null"); } }

public override string ToString() { return Value; }
public static implicit operator String(InputType v) { return v.Value; }
Expand Down Expand Up @@ -77,7 +77,7 @@ public Input(InputType type) {
public List<object>? ArrayOfany { get; set; }
public double? Number { get; set; }

public InputType Type {get; set; }
public InputType Type { get; set; }


public static Input CreateMapOfany(Dictionary<string, object> mapOfany) {
Expand Down Expand Up @@ -141,7 +141,7 @@ public class InputConverter : JsonConverter
}
try
{
Dictionary<string, object>? mapOfany = JsonConvert.DeserializeObject<Dictionary<string, object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(Dictionary<string, object>), "string")});
Dictionary<string, object>? mapOfany = JsonConvert.DeserializeObject<Dictionary<string, object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(Dictionary<string, object>))});
return new Input(InputType.MapOfany) {
MapOfany = mapOfany
};
Expand All @@ -167,7 +167,7 @@ public class InputConverter : JsonConverter
}
try
{
List<object>? arrayOfany = JsonConvert.DeserializeObject<List<object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(List<object>), "string")});
List<object>? arrayOfany = JsonConvert.DeserializeObject<List<object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(List<object>))});
return new Input(InputType.ArrayOfany) {
ArrayOfany = arrayOfany
};
Expand Down Expand Up @@ -233,5 +233,4 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer

}


}
9 changes: 4 additions & 5 deletions Api/Models/Components/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ResultType

public static ResultType Number { get { return new ResultType("number"); } }

public static ResultType Null { get { return new ResultType("null"); } }
public static ResultType Null { get { return new ResultType("null"); } }

public override string ToString() { return Value; }
public static implicit operator String(ResultType v) { return v.Value; }
Expand Down Expand Up @@ -77,7 +77,7 @@ public Result(ResultType type) {
public List<object>? ArrayOfany { get; set; }
public double? Number { get; set; }

public ResultType Type {get; set; }
public ResultType Type { get; set; }


public static Result CreateMapOfany(Dictionary<string, object> mapOfany) {
Expand Down Expand Up @@ -141,7 +141,7 @@ public class ResultConverter : JsonConverter
}
try
{
Dictionary<string, object>? mapOfany = JsonConvert.DeserializeObject<Dictionary<string, object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(Dictionary<string, object>), "string")});
Dictionary<string, object>? mapOfany = JsonConvert.DeserializeObject<Dictionary<string, object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(Dictionary<string, object>))});
return new Result(ResultType.MapOfany) {
MapOfany = mapOfany
};
Expand All @@ -167,7 +167,7 @@ public class ResultConverter : JsonConverter
}
try
{
List<object>? arrayOfany = JsonConvert.DeserializeObject<List<object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(List<object>), "string")});
List<object>? arrayOfany = JsonConvert.DeserializeObject<List<object>>(json, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Error, Converters = Utilities.GetJsonConverters(typeof(List<object>))});
return new Result(ResultType.ArrayOfany) {
ArrayOfany = arrayOfany
};
Expand Down Expand Up @@ -233,5 +233,4 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer

}


}
22 changes: 11 additions & 11 deletions Api/Opa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public class Opa: IOpa
public SDKConfig SDKConfiguration { get; private set; }

private const string _language = "csharp";
private const string _sdkVersion = "0.1.0";
private const string _sdkGenVersion = "2.283.1";
private const string _sdkVersion = "0.1.1";
private const string _sdkGenVersion = "2.291.0";
private const string _openapiDocVersion = "0.2.0";
private const string _userAgent = "speakeasy-sdk/csharp 0.1.0 2.283.1 0.2.0 api";
private const string _userAgent = "speakeasy-sdk/csharp 0.1.1 2.291.0 0.2.0 api";
private string _serverUrl = "";
private int _serverIndex = 0;
private ISpeakeasyHttpClient _defaultClient;
Expand Down Expand Up @@ -142,7 +142,7 @@ public async Task<ExecutePolicyResponse> ExecutePolicyAsync(ExecutePolicyRequest
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.SuccessfulPolicyEvaluation = JsonConvert.DeserializeObject<SuccessfulPolicyEvaluation>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.SuccessfulPolicyEvaluation = JsonConvert.DeserializeObject<SuccessfulPolicyEvaluation>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand All @@ -152,7 +152,7 @@ public async Task<ExecutePolicyResponse> ExecutePolicyAsync(ExecutePolicyRequest
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.ClientError = JsonConvert.DeserializeObject<ClientError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.ClientError = JsonConvert.DeserializeObject<ClientError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand All @@ -162,7 +162,7 @@ public async Task<ExecutePolicyResponse> ExecutePolicyAsync(ExecutePolicyRequest
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.ServerError = JsonConvert.DeserializeObject<ServerError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.ServerError = JsonConvert.DeserializeObject<ServerError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand Down Expand Up @@ -203,7 +203,7 @@ public async Task<ExecutePolicyWithInputResponse> ExecutePolicyWithInputAsync(Ex
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.SuccessfulPolicyEvaluation = JsonConvert.DeserializeObject<SuccessfulPolicyEvaluation>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.SuccessfulPolicyEvaluation = JsonConvert.DeserializeObject<SuccessfulPolicyEvaluation>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand All @@ -213,7 +213,7 @@ public async Task<ExecutePolicyWithInputResponse> ExecutePolicyWithInputAsync(Ex
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.ClientError = JsonConvert.DeserializeObject<ClientError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.ClientError = JsonConvert.DeserializeObject<ClientError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand All @@ -223,7 +223,7 @@ public async Task<ExecutePolicyWithInputResponse> ExecutePolicyWithInputAsync(Ex
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.ServerError = JsonConvert.DeserializeObject<ServerError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.ServerError = JsonConvert.DeserializeObject<ServerError>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand Down Expand Up @@ -263,7 +263,7 @@ public async Task<HealthResponse> HealthAsync(bool? bundles = null, bool? plugin
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.HealthyServer = JsonConvert.DeserializeObject<HealthyServer>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.HealthyServer = JsonConvert.DeserializeObject<HealthyServer>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand All @@ -273,7 +273,7 @@ public async Task<HealthResponse> HealthAsync(bool? bundles = null, bool? plugin
{
if(Utilities.IsContentTypeMatch("application/json",response.ContentType))
{
response.UnhealthyServer = JsonConvert.DeserializeObject<UnhealthyServer>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumSerializer() }});
response.UnhealthyServer = JsonConvert.DeserializeObject<UnhealthyServer>(await httpResponse.Content.ReadAsStringAsync(), new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new EnumConverter(), new AnyDeserializer() }});
}

return response;
Expand Down
92 changes: 92 additions & 0 deletions Api/Utils/AnyDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace Api.Utils
{
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;

public class AnyDeserializer : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(Dictionary<string, object>));
}

public override bool CanWrite => false;

public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
throw new NotSupportedException();
}

public override object ReadJson(
JsonReader reader,
Type objectType,
object? existingValue,
JsonSerializer serializer
)
{
return ParseTokenIntoDictionary(JToken.Load(reader));
}

private Dictionary<string, object?> ParseTokenIntoDictionary(JToken token)
{
var dict = new Dictionary<string, object?>();

foreach (var child in token.Children<JProperty>())
{

object? val = null;
if (child.Value is JObject)
{
val = ParseTokenIntoDictionary(child.Value);
}
else if (child.Value is JArray)
{
val = ParseTokenIntoList(child.Value);
}
else if (child.Value != null)
{
val = ((JValue)child.Value).Value;
}

dict[child.Name] = val;
}

return dict;
}

private List<object?> ParseTokenIntoList(JToken token)
{
var list = new List<object?>();

foreach (var child in token.Children())
{
if (child is JObject)
{
list.Add((object)ParseTokenIntoDictionary(child));
}
else if (child is JArray)
{
list.Add((object)ParseTokenIntoList(child));
}
else
{
list.Add(((JValue)child).Value);
}
}

return list;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ namespace Api.Utils
using System.Globalization;
using System.Numerics;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

internal class BigIntSerializer : JsonConverter
internal class BigIntStrConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
var nullableType = Nullable.GetUnderlyingType(objectType);
var nullableType = Nullable.GetUnderlyingType(objectType);
if (nullableType != null)
{
return nullableType == typeof(BigInteger);
Expand All @@ -28,8 +29,6 @@ public override bool CanConvert(Type objectType)
return objectType == typeof(BigInteger);
}

public override bool CanRead => true;

public override object? ReadJson(
JsonReader reader,
Type objectType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace Api.Utils
using System;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

internal class DecimalSerializer : JsonConverter
internal class DecimalStrConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
Expand All @@ -27,8 +28,6 @@ public override bool CanConvert(Type objectType)
return objectType == typeof(Decimal);
}

public override bool CanRead => true;

public override object? ReadJson(
JsonReader reader,
Type objectType,
Expand All @@ -41,7 +40,11 @@ JsonSerializer serializer
return null;
}

return Decimal.Parse(reader.Value.ToString()!);
try {
return Decimal.Parse(reader.Value.ToString()!);
} catch (System.FormatException ex) {
throw new Newtonsoft.Json.JsonSerializationException("Could not parse Decimal", ex);
}
}

public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
Expand Down
Loading
Loading