forked from loafle/openapi-generator-original
[C#] Fix oneOf derserialization with additional properties (#8057)
* fix oneOf derserializaoneOf deserialization with additonal prop * fix tests due to better handlding of additional prop
This commit is contained in:
parent
b0ecaab8fb
commit
bcf4f8ade6
@ -28,6 +28,23 @@ namespace {{packageName}}.{{modelPackage}}
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom JSON serializer for objects with additional properties
|
||||||
|
/// </summary>
|
||||||
|
static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
// OpenAPI generated types generally hide default constructors.
|
||||||
|
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||||
|
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||||
|
ContractResolver = new DefaultContractResolver
|
||||||
|
{
|
||||||
|
NamingStrategy = new CamelCaseNamingStrategy
|
||||||
|
{
|
||||||
|
OverrideSpecifiedNames = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets the actual instance
|
/// Gets or Sets the actual instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -112,7 +112,12 @@
|
|||||||
{
|
{
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
case "{{{mappingName}}}":
|
case "{{{mappingName}}}":
|
||||||
|
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{modelName}}}>(jsonString, {{classname}}.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (new{{{classname}}}.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{modelName}}}>(jsonString, {{classname}}.SerializerSettings));
|
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{modelName}}}>(jsonString, {{classname}}.SerializerSettings));
|
||||||
|
}
|
||||||
return new{{classname}};
|
return new{{classname}};
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
default:
|
default:
|
||||||
@ -127,8 +132,13 @@
|
|||||||
{{#oneOf}}
|
{{#oneOf}}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{.}}}>(jsonString, {{classname}}.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (new{{{classname}}}.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{.}}}>(jsonString, {{classname}}.SerializerSettings));
|
new{{classname}} = new {{classname}}(JsonConvert.DeserializeObject<{{{.}}}>(jsonString, {{classname}}.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("{{{.}}}");
|
matchedTypes.Add("{{{.}}}");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,23 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom JSON serializer for objects with additional properties
|
||||||
|
/// </summary>
|
||||||
|
static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
// OpenAPI generated types generally hide default constructors.
|
||||||
|
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||||
|
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||||
|
ContractResolver = new DefaultContractResolver
|
||||||
|
{
|
||||||
|
NamingStrategy = new CamelCaseNamingStrategy
|
||||||
|
{
|
||||||
|
OverrideSpecifiedNames = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets the actual instance
|
/// Gets or Sets the actual instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -146,8 +146,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruit.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Apple");
|
matchedTypes.Add("Apple");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -158,8 +163,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruit.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Banana");
|
matchedTypes.Add("Banana");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -155,8 +155,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruitReq.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("AppleReq");
|
matchedTypes.Add("AppleReq");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -167,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruitReq.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("BananaReq");
|
matchedTypes.Add("BananaReq");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,28 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Pig":
|
case "Pig":
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
return newMammal;
|
return newMammal;
|
||||||
case "whale":
|
case "whale":
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
return newMammal;
|
return newMammal;
|
||||||
case "zebra":
|
case "zebra":
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
return newMammal;
|
return newMammal;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
||||||
@ -191,8 +206,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Pig");
|
matchedTypes.Add("Pig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -203,8 +223,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Whale");
|
matchedTypes.Add("Whale");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -215,8 +240,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Zebra");
|
matchedTypes.Add("Zebra");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Quadrilateral":
|
case "Quadrilateral":
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
return newNullableShape;
|
return newNullableShape;
|
||||||
case "Triangle":
|
case "Triangle":
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
return newNullableShape;
|
return newNullableShape;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||||
@ -171,8 +181,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -183,8 +198,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "BasquePig":
|
case "BasquePig":
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
return newPig;
|
return newPig;
|
||||||
case "DanishPig":
|
case "DanishPig":
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
return newPig;
|
return newPig;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
||||||
@ -162,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("BasquePig");
|
matchedTypes.Add("BasquePig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -174,8 +189,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("DanishPig");
|
matchedTypes.Add("DanishPig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "ComplexQuadrilateral":
|
case "ComplexQuadrilateral":
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
return newQuadrilateral;
|
return newQuadrilateral;
|
||||||
case "SimpleQuadrilateral":
|
case "SimpleQuadrilateral":
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
return newQuadrilateral;
|
return newQuadrilateral;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
||||||
@ -162,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("ComplexQuadrilateral");
|
matchedTypes.Add("ComplexQuadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -174,8 +189,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("SimpleQuadrilateral");
|
matchedTypes.Add("SimpleQuadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Quadrilateral":
|
case "Quadrilateral":
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
return newShape;
|
return newShape;
|
||||||
case "Triangle":
|
case "Triangle":
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
return newShape;
|
return newShape;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||||
@ -162,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -174,8 +189,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Quadrilateral":
|
case "Quadrilateral":
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
return newShapeOrNull;
|
return newShapeOrNull;
|
||||||
case "Triangle":
|
case "Triangle":
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
return newShapeOrNull;
|
return newShapeOrNull;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||||
@ -171,8 +181,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -183,8 +198,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,28 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "EquilateralTriangle":
|
case "EquilateralTriangle":
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
return newTriangle;
|
return newTriangle;
|
||||||
case "IsoscelesTriangle":
|
case "IsoscelesTriangle":
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
return newTriangle;
|
return newTriangle;
|
||||||
case "ScaleneTriangle":
|
case "ScaleneTriangle":
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
return newTriangle;
|
return newTriangle;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
||||||
@ -191,8 +206,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("EquilateralTriangle");
|
matchedTypes.Add("EquilateralTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -203,8 +223,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("IsoscelesTriangle");
|
matchedTypes.Add("IsoscelesTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -215,8 +240,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("ScaleneTriangle");
|
matchedTypes.Add("ScaleneTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,8 @@ namespace Org.OpenAPITools.Test
|
|||||||
Assert.IsType<Banana>(f3.ActualInstance);
|
Assert.IsType<Banana>(f3.ActualInstance);
|
||||||
|
|
||||||
Fruit f4 = Fruit.FromJson("{\"origin\":\"Japan\"}");
|
Fruit f4 = Fruit.FromJson("{\"origin\":\"Japan\"}");
|
||||||
Assert.IsType<Apple>(f4.ActualInstance);
|
// since banana allows additional properties, it will apple's JSON payload as well
|
||||||
|
Assert.IsType<Banana>(f4.ActualInstance);
|
||||||
|
|
||||||
// test custom deserializer
|
// test custom deserializer
|
||||||
Fruit f5 = JsonConvert.DeserializeObject<Fruit>("{\"lengthCm\":98}");
|
Fruit f5 = JsonConvert.DeserializeObject<Fruit>("{\"lengthCm\":98}");
|
||||||
@ -117,5 +118,18 @@ namespace Org.OpenAPITools.Test
|
|||||||
Cat c = JsonConvert.DeserializeObject<Cat>("{\"className\":\"cat\",\"bar\":\"from json bar\"}");
|
Cat c = JsonConvert.DeserializeObject<Cat>("{\"className\":\"cat\",\"bar\":\"from json bar\"}");
|
||||||
Assert.Equal("from json bar", c.AdditionalProperties["bar"]);
|
Assert.Equal("from json bar", c.AdditionalProperties["bar"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test additonal properties
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void TestAdditionalProperties()
|
||||||
|
{
|
||||||
|
Foo f = new Foo();
|
||||||
|
|
||||||
|
Assert.NotNull(f.GetType().GetProperty("AdditionalProperties"));
|
||||||
|
Assert.Null(f.GetType().GetProperty("unknown_property"));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,6 +36,23 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom JSON serializer for objects with additional properties
|
||||||
|
/// </summary>
|
||||||
|
static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
// OpenAPI generated types generally hide default constructors.
|
||||||
|
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||||
|
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||||
|
ContractResolver = new DefaultContractResolver
|
||||||
|
{
|
||||||
|
NamingStrategy = new CamelCaseNamingStrategy
|
||||||
|
{
|
||||||
|
OverrideSpecifiedNames = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets the actual instance
|
/// Gets or Sets the actual instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -146,8 +146,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruit.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Apple");
|
matchedTypes.Add("Apple");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -158,8 +163,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruit.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Banana");
|
matchedTypes.Add("Banana");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -155,8 +155,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruitReq.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("AppleReq");
|
matchedTypes.Add("AppleReq");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -167,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruitReq.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("BananaReq");
|
matchedTypes.Add("BananaReq");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,28 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Pig":
|
case "Pig":
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
return newMammal;
|
return newMammal;
|
||||||
case "whale":
|
case "whale":
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
return newMammal;
|
return newMammal;
|
||||||
case "zebra":
|
case "zebra":
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
return newMammal;
|
return newMammal;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
||||||
@ -191,8 +206,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Pig");
|
matchedTypes.Add("Pig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -203,8 +223,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Whale");
|
matchedTypes.Add("Whale");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -215,8 +240,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Zebra");
|
matchedTypes.Add("Zebra");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Quadrilateral":
|
case "Quadrilateral":
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
return newNullableShape;
|
return newNullableShape;
|
||||||
case "Triangle":
|
case "Triangle":
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
return newNullableShape;
|
return newNullableShape;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||||
@ -171,8 +181,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -183,8 +198,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "BasquePig":
|
case "BasquePig":
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
return newPig;
|
return newPig;
|
||||||
case "DanishPig":
|
case "DanishPig":
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
return newPig;
|
return newPig;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
||||||
@ -162,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("BasquePig");
|
matchedTypes.Add("BasquePig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -174,8 +189,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("DanishPig");
|
matchedTypes.Add("DanishPig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "ComplexQuadrilateral":
|
case "ComplexQuadrilateral":
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
return newQuadrilateral;
|
return newQuadrilateral;
|
||||||
case "SimpleQuadrilateral":
|
case "SimpleQuadrilateral":
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
return newQuadrilateral;
|
return newQuadrilateral;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
||||||
@ -162,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("ComplexQuadrilateral");
|
matchedTypes.Add("ComplexQuadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -174,8 +189,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("SimpleQuadrilateral");
|
matchedTypes.Add("SimpleQuadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +148,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Quadrilateral":
|
case "Quadrilateral":
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
return newShape;
|
return newShape;
|
||||||
case "Triangle":
|
case "Triangle":
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
return newShape;
|
return newShape;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||||
@ -162,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -174,8 +189,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,20 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "Quadrilateral":
|
case "Quadrilateral":
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
return newShapeOrNull;
|
return newShapeOrNull;
|
||||||
case "Triangle":
|
case "Triangle":
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
return newShapeOrNull;
|
return newShapeOrNull;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||||
@ -171,8 +181,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -183,8 +198,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,28 @@ namespace Org.OpenAPITools.Model
|
|||||||
switch (discriminatorValue)
|
switch (discriminatorValue)
|
||||||
{
|
{
|
||||||
case "EquilateralTriangle":
|
case "EquilateralTriangle":
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
return newTriangle;
|
return newTriangle;
|
||||||
case "IsoscelesTriangle":
|
case "IsoscelesTriangle":
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
return newTriangle;
|
return newTriangle;
|
||||||
case "ScaleneTriangle":
|
case "ScaleneTriangle":
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
return newTriangle;
|
return newTriangle;
|
||||||
default:
|
default:
|
||||||
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
System.Diagnostics.Debug.WriteLine(String.Format("Failed to lookup discriminator value `{0}` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
||||||
@ -191,8 +206,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("EquilateralTriangle");
|
matchedTypes.Add("EquilateralTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -203,8 +223,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("IsoscelesTriangle");
|
matchedTypes.Add("IsoscelesTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -215,8 +240,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("ScaleneTriangle");
|
matchedTypes.Add("ScaleneTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,23 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom JSON serializer for objects with additional properties
|
||||||
|
/// </summary>
|
||||||
|
static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
// OpenAPI generated types generally hide default constructors.
|
||||||
|
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||||
|
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||||
|
ContractResolver = new DefaultContractResolver
|
||||||
|
{
|
||||||
|
NamingStrategy = new CamelCaseNamingStrategy
|
||||||
|
{
|
||||||
|
OverrideSpecifiedNames = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets the actual instance
|
/// Gets or Sets the actual instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -146,8 +146,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruit.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Apple>(jsonString, Fruit.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Apple");
|
matchedTypes.Add("Apple");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -158,8 +163,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruit.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
newFruit = new Fruit(JsonConvert.DeserializeObject<Banana>(jsonString, Fruit.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Banana");
|
matchedTypes.Add("Banana");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -155,8 +155,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruitReq.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<AppleReq>(jsonString, FruitReq.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("AppleReq");
|
matchedTypes.Add("AppleReq");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -167,8 +172,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newFruitReq.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
newFruitReq = new FruitReq(JsonConvert.DeserializeObject<BananaReq>(jsonString, FruitReq.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("BananaReq");
|
matchedTypes.Add("BananaReq");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Pig>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Pig");
|
matchedTypes.Add("Pig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -185,8 +190,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Whale>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Whale");
|
matchedTypes.Add("Whale");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -197,8 +207,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newMammal.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
newMammal = new Mammal(JsonConvert.DeserializeObject<Zebra>(jsonString, Mammal.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Zebra");
|
matchedTypes.Add("Zebra");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -156,8 +156,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -168,8 +173,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newNullableShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
newNullableShape = new NullableShape(JsonConvert.DeserializeObject<Triangle>(jsonString, NullableShape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<BasquePig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("BasquePig");
|
matchedTypes.Add("BasquePig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -159,8 +164,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newPig.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
newPig = new Pig(JsonConvert.DeserializeObject<DanishPig>(jsonString, Pig.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("DanishPig");
|
matchedTypes.Add("DanishPig");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<ComplexQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("ComplexQuadrilateral");
|
matchedTypes.Add("ComplexQuadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -159,8 +164,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newQuadrilateral.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
newQuadrilateral = new Quadrilateral(JsonConvert.DeserializeObject<SimpleQuadrilateral>(jsonString, Quadrilateral.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("SimpleQuadrilateral");
|
matchedTypes.Add("SimpleQuadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -159,8 +164,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShape.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
newShape = new Shape(JsonConvert.DeserializeObject<Triangle>(jsonString, Shape.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -156,8 +156,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Quadrilateral>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Quadrilateral");
|
matchedTypes.Add("Quadrilateral");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -168,8 +173,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newShapeOrNull.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
newShapeOrNull = new ShapeOrNull(JsonConvert.DeserializeObject<Triangle>(jsonString, ShapeOrNull.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("Triangle");
|
matchedTypes.Add("Triangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
List<string> matchedTypes = new List<string>();
|
List<string> matchedTypes = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<EquilateralTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("EquilateralTriangle");
|
matchedTypes.Add("EquilateralTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -185,8 +190,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<IsoscelesTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("IsoscelesTriangle");
|
matchedTypes.Add("IsoscelesTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
@ -197,8 +207,13 @@ namespace Org.OpenAPITools.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.AdditionalPropertiesSerializerSettings));
|
||||||
|
// if it does not contains "AdditionalProperties", use SerializerSettings to deserialize
|
||||||
|
if (newTriangle.GetType().GetProperty("AdditionalProperties") == null)
|
||||||
{
|
{
|
||||||
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
newTriangle = new Triangle(JsonConvert.DeserializeObject<ScaleneTriangle>(jsonString, Triangle.SerializerSettings));
|
||||||
|
}
|
||||||
matchedTypes.Add("ScaleneTriangle");
|
matchedTypes.Add("ScaleneTriangle");
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user