Skip to content

Commit

Permalink
fix(*): add "override" for "Type"
Browse files Browse the repository at this point in the history
  • Loading branch information
MingboPeng committed May 10, 2023
1 parent 4b1e7b4 commit d91bc3b
Show file tree
Hide file tree
Showing 267 changed files with 374 additions and 653 deletions.
11 changes: 11 additions & 0 deletions .openapi-generator/post_gen_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ def replace_decimal(read_data):
return data


def add_override_to_type_property(read_data):
data = read_data
replace_source = "public string Type { get; protected set; }"
replace_new = "public override string Type { get; protected set; }"
rex = replace_source
if re.findall(rex, data) != []:
data = re.sub(rex, replace_new, data)
return data


def replace_AnyType(read_data):
data = read_data
replace_source = ['AnyType']
Expand Down Expand Up @@ -234,6 +244,7 @@ def check_csfiles(source_folder, anyof_types):
# replace decimal/number to double
# data = replace_decimal(data)
data = fix_constructor(data)
data = add_override_to_type_property(data)

# remove spec parameter in DAG inputs's Equals
data = remove_spec_in_equals(data)
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK.Tests/TestInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestInit
[OneTimeSetUp]
public void Init()
{
var useDevelopmentServer = true;
var useDevelopmentServer = false;
var key = string.Empty;

// for local development tests, you must add Api key to ApiKey.txt
Expand Down
40 changes: 37 additions & 3 deletions src/PollinationSDK/ManuallyAdded/BaseClass/PollinationObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace PollinationSDK
{
public abstract class PollinationObject
public abstract class PollinationObject : IPollinationObject
{
/// <summary>
/// Gets or Sets Type
Expand All @@ -24,10 +24,44 @@ protected internal PollinationObject()
public abstract string ToString(bool detailed);

public abstract OpenAPIGenBaseModel Duplicate();
public string ToJson()

public string ToJson(bool indented = false)
{
return JsonConvert.SerializeObject(this, Formatting.Indented, JsonSetting.AnyOfConvertSetting);
var format = indented ? Formatting.Indented : Formatting.None;
return JsonConvert.SerializeObject(this, format, JsonSetting.AnyOfConvertSetting);
}

public static bool operator == (PollinationObject left, PollinationObject right)
{
if (left is null)
{
if (right is null)
{
return true;
}

// Only the left side is null.
return false;
}
// Equals handles case of null on right side.
return left.Equals(right);
}

public static bool operator !=(PollinationObject left, PollinationObject right)
{
return !(left == right);
}

public override bool Equals(object obj)
{
if (obj == null)
return false;
if (obj is PollinationObject input)
return Extension.Equals(this.Type, input.Type);
return false;
}


}
}

13 changes: 13 additions & 0 deletions src/PollinationSDK/ManuallyAdded/Interface/IPollinationObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

namespace PollinationSDK
{
public interface IPollinationObject
{
string ToString(bool detailed);
string ToJson(bool indented = false);
OpenAPIGenBaseModel Duplicate();
}


}

51 changes: 51 additions & 0 deletions src/PollinationSDK/ManuallyAdded/Model/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@

using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;

namespace PollinationSDK
{
public static class ModelExtensions
{
public static bool AllEquals(IList x, IList y)
{
if (x != null && y != null)
{
if (x.Count <= 0 || y.Count <= 0)
return x.Count == y.Count;

if (x[0] is IList listX && y[0] is IList listY)
{
return AllEquals(listX, listY);
}
else
{
var xo = x.Cast<object>();
var yo = y.Cast<object>();
return xo.SequenceEqual(yo);
}
}
else if (x == null)
{
return y == null || y.Count == 0;
}
else if (y == null)
{
return x == null || x.Count == 0;
}
else
{
return x == y;
}
}

public static bool Equals(object x, object y)
{

if (x == y)
return true;

if (x == null)
return y == null;

if (x is JObject j)
return JToken.DeepEquals(j, y as JObject);
else
return x.Equals(y);

}

public static List<Interface.Io.Outputs.IDag> GetOutputs(this RecipeInterface recipe)
{
var outputs = recipe.Outputs
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/APIToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public APIToken
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "APIToken";
public override string Type { get; protected internal set; } = "APIToken";

/// <summary>
/// The unique ID of this API token
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/APITokenCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public APITokenCreate
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "APITokenCreate";
public override string Type { get; protected internal set; } = "APITokenCreate";


/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/APITokenList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public APITokenList
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "APITokenList";
public override string Type { get; protected internal set; } = "APITokenList";

/// <summary>
/// The current page the pagination request is on
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/APITokenPrivate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public APITokenPrivate
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "APITokenPrivate";
public override string Type { get; protected internal set; } = "APITokenPrivate";

/// <summary>
/// The decoded API token
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/AccessPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public AccessPolicy
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "AccessPolicy";
public override string Type { get; protected internal set; } = "AccessPolicy";

/// <summary>
/// The subject of the access policy
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/AccessPolicyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public AccessPolicyList
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "AccessPolicyList";
public override string Type { get; protected internal set; } = "AccessPolicyList";

/// <summary>
/// The current page the pagination request is on
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/Accessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Accessor
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "Accessor";
public override string Type { get; protected internal set; } = "Accessor";

/// <summary>
/// Gets or Sets Subject
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/AccountPublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public AccountPublic
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "AccountPublic";
public override string Type { get; protected internal set; } = "AccountPublic";

/// <summary>
/// Gets or Sets Id
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/Activation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Activation
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "Activation";
public override string Type { get; protected internal set; } = "Activation";

/// <summary>
/// Gets or Sets Id
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/ActivationList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ActivationList
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "ActivationList";
public override string Type { get; protected internal set; } = "ActivationList";

/// <summary>
/// Gets or Sets Resources
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/ArtifactSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ArtifactSource
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "_ArtifactSource";
public override string Type { get; protected internal set; } = "_ArtifactSource";

/// <summary>
/// An optional dictionary to add annotations to inputs. These annotations will be used by the client side libraries.
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/BakedRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public BakedRecipe
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "BakedRecipe";
public override string Type { get; protected internal set; } = "BakedRecipe";

/// <summary>
/// A list of tasks to create a DAG recipe.
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/BaseList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public BaseList
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "BaseList";
public override string Type { get; protected internal set; } = "BaseList";

/// <summary>
/// Gets or Sets HasMore
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/BaseReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public BaseReference
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "_BaseReference";
public override string Type { get; protected internal set; } = "_BaseReference";

/// <summary>
/// An optional dictionary to add annotations to inputs. These annotations will be used by the client side libraries.
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/BaseStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public BaseStatus
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "BaseStatus";
public override string Type { get; protected internal set; } = "BaseStatus";

/// <summary>
/// The time at which the task was started
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/BodyPostPluginOwnerPluginsPost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BodyPostPluginOwnerPluginsPost
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "Body_post_plugin__owner__plugins_post";
public override string Type { get; protected internal set; } = "Body_post_plugin__owner__plugins_post";

/// <summary>
/// Gets or Sets Package
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/BodyPostRecipeOwnerRecipesPost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BodyPostRecipeOwnerRecipesPost
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "Body_post_recipe__owner__recipes_post";
public override string Type { get; protected internal set; } = "Body_post_recipe__owner__recipes_post";

/// <summary>
/// Gets or Sets Package
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/CardPublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public CardPublic
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "CardPublic";
public override string Type { get; protected internal set; } = "CardPublic";

/// <summary>
/// The last four digits of the card
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/CloudJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public CloudJob
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "CloudJob";
public override string Type { get; protected internal set; } = "CloudJob";

/// <summary>
/// The unique ID for this run
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/CloudJobList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public CloudJobList
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "CloudJobList";
public override string Type { get; protected internal set; } = "CloudJobList";

/// <summary>
/// The current page the pagination request is on
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/Coupon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Coupon
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "Coupon";
public override string Type { get; protected internal set; } = "Coupon";

/// <summary>
/// Gets or Sets Name
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/CreatedContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public CreatedContent
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "CreatedContent";
public override string Type { get; protected internal set; } = "CreatedContent";

/// <summary>
/// Id for the newly created resource.
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/CryptlexBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CryptlexBase
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "CryptlexBase";
public override string Type { get; protected internal set; } = "CryptlexBase";


/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/DAG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public DAG
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "DAG";
public override string Type { get; protected internal set; } = "DAG";

/// <summary>
/// A unique name for this dag.
Expand Down
2 changes: 1 addition & 1 deletion src/PollinationSDK/Model/DAGArrayInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public DAGArrayInput
/// Gets or Sets Type
/// </summary>
[DataMember(Name = "type", EmitDefaultValue = true)]
public string Type { get; protected internal set; } = "DAGArrayInput";
public override string Type { get; protected internal set; } = "DAGArrayInput";

/// <summary>
/// Default value to use for an input if a value was not supplied.
Expand Down
Loading

0 comments on commit d91bc3b

Please sign in to comment.