mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 12:32:42 +00:00
[csharp] Support inheritance instead of duplicating parent properties in derived classes (#5922)
* [csharp] Explicitly set supportsInheritance * [csharp] set supportsInheritance for client This includes supportsInheritance only for the client codegen at the moment, because setting in AbstractCSharpCodegen would require the change to be tested in all derived generators, possibly including similar template changes to this commit's. * include nice improvement of https://github.com/jimschubert/swagger-codegen/tree/csharp/3829 and leverage https://github.com/manuc66/JsonSubTypes for subtype deserialization * remove duplicate base validations * remove useless tests * restore documentation for properties coming from parent * launch bin/security/csharp-petstore.sh * it's impossible to call an explicitly implemented interface-method on the base class (https://stackoverflow.com/questions/5976216/how-to-call-an-explicitly-implemented-interface-method-on-the-base-class) * restore portion of code that was lost * regenerate more * fix missing using * take the multi .net compatible revision * keep generated model simple when no hierarchy involved * regenerate with: - bin/csharp-petstore-all.sh && bin/security/csharp-petstore.sh - bin/csharp-dotnet2-petstore.sh && bin/csharp-petstore.sh && bin/csharp-petstore-netcore-project.sh && bin/csharp-petstore-net-standard.sh && bin/csharp-property-changed-petstore.sh * fix sln indentation and the missing windows runner for dotnet2 * fix inheritance GetHashCode and Equals * override instead of hiding the base method + fix the csharp-property-changed-petstore.bat * By default the value of the discriminator property must be the name of the current schema * Add test for subtype deserialisation from parent type * add missing '.bat' and use the 'call' template from javascript-petstore-all.bat add missing file to trigger it on windows * fix default value bug * cleanup copyright information * formatting after merge * fix merge * applying bin/csharp-petstore-all.sh * applying bin/security/csharp-petstore.sh
This commit is contained in:
@@ -7,21 +7,21 @@ EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -8,6 +8,7 @@ using IO.Swagger.Api;
|
||||
using IO.Swagger.Model;
|
||||
using IO.Swagger.Client;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Test
|
||||
{
|
||||
@@ -50,6 +51,25 @@ namespace IO.Swagger.Test
|
||||
Assert.IsInstanceOfType(typeof(Animal), instance, "instance is a Animal");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test deserialize a Dog from type Animal
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DogDeserializeFromAnimalTest()
|
||||
{
|
||||
// TODO uncomment below to test deserialize a Dog from type Animal
|
||||
//Assert.IsInstanceOf<Animal>(JsonConvert.DeserializeObject<Animal>(new Dog().ToJson()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Test deserialize a Cat from type Animal
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void CatDeserializeFromAnimalTest()
|
||||
{
|
||||
// TODO uncomment below to test deserialize a Cat from type Animal
|
||||
//Assert.IsInstanceOf<Animal>(JsonConvert.DeserializeObject<Animal>(new Cat().ToJson()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ClassName'
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace JsonSubTypes
|
||||
{
|
||||
// Copied from project https://github.com/manuc66/JsonSubTypes
|
||||
// https://raw.githubusercontent.com/manuc66/JsonSubTypes/07403192ea3f4959f6d42f5966ac56ceb0d6095b/JsonSubTypes/JsonSubtypes.cs
|
||||
|
||||
public class JsonSubtypes : JsonConverter
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
|
||||
public class KnownSubTypeAttribute : Attribute
|
||||
{
|
||||
public Type SubType { get; private set; }
|
||||
public object AssociatedValue { get; private set; }
|
||||
|
||||
public KnownSubTypeAttribute(Type subType, object associatedValue)
|
||||
{
|
||||
SubType = subType;
|
||||
AssociatedValue = associatedValue;
|
||||
}
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
|
||||
public class KnownSubTypeWithPropertyAttribute : Attribute
|
||||
{
|
||||
public Type SubType { get; private set; }
|
||||
public string PropertyName { get; private set; }
|
||||
|
||||
public KnownSubTypeWithPropertyAttribute(Type subType, string propertyName)
|
||||
{
|
||||
SubType = subType;
|
||||
PropertyName = propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string _typeMappingPropertyName;
|
||||
|
||||
private bool _isInsideRead;
|
||||
private JsonReader _reader;
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_isInsideRead)
|
||||
return true;
|
||||
|
||||
return !string.IsNullOrEmpty(_reader.Path);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public JsonSubtypes()
|
||||
{
|
||||
}
|
||||
|
||||
public JsonSubtypes(string typeMappingPropertyName)
|
||||
{
|
||||
_typeMappingPropertyName = typeMappingPropertyName;
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return _typeMappingPropertyName != null;
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Comment)
|
||||
reader.Read();
|
||||
|
||||
switch (reader.TokenType)
|
||||
{
|
||||
case JsonToken.Null:
|
||||
return null;
|
||||
case JsonToken.StartArray:
|
||||
return ReadArray(reader, objectType, serializer);
|
||||
case JsonToken.StartObject:
|
||||
return ReadObject(reader, objectType, serializer);
|
||||
default:
|
||||
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
|
||||
}
|
||||
}
|
||||
|
||||
private IList ReadArray(JsonReader reader, Type targetType, JsonSerializer serializer)
|
||||
{
|
||||
var elementType = GetElementType(targetType);
|
||||
|
||||
var list = CreateCompatibleList(targetType, elementType);
|
||||
|
||||
while (reader.TokenType != JsonToken.EndArray && reader.Read())
|
||||
{
|
||||
switch (reader.TokenType)
|
||||
{
|
||||
case JsonToken.Null:
|
||||
list.Add(reader.Value);
|
||||
break;
|
||||
case JsonToken.Comment:
|
||||
break;
|
||||
case JsonToken.StartObject:
|
||||
list.Add(ReadObject(reader, elementType, serializer));
|
||||
break;
|
||||
case JsonToken.EndArray:
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
|
||||
}
|
||||
}
|
||||
if (targetType.IsArray)
|
||||
{
|
||||
var array = Array.CreateInstance(targetType.GetElementType(), list.Count);
|
||||
list.CopyTo(array, 0);
|
||||
list = array;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static IList CreateCompatibleList(Type targetContainerType, Type elementType)
|
||||
{
|
||||
IList list;
|
||||
if (targetContainerType.IsArray || targetContainerType.GetTypeInfo().IsAbstract)
|
||||
{
|
||||
list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType));
|
||||
}
|
||||
else
|
||||
{
|
||||
list = (IList)Activator.CreateInstance(targetContainerType);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static Type GetElementType(Type arrayOrGenericContainer)
|
||||
{
|
||||
Type elementType;
|
||||
if (arrayOrGenericContainer.IsArray)
|
||||
{
|
||||
elementType = arrayOrGenericContainer.GetElementType();
|
||||
}
|
||||
else
|
||||
{
|
||||
elementType = arrayOrGenericContainer.GenericTypeArguments[0];
|
||||
}
|
||||
return elementType;
|
||||
}
|
||||
|
||||
private object ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer)
|
||||
{
|
||||
var jObject = JObject.Load(reader);
|
||||
|
||||
var targetType = GetType(jObject, objectType) ?? objectType;
|
||||
|
||||
return _ReadJson(CreateAnotherReader(jObject, reader), targetType, null, serializer);
|
||||
}
|
||||
|
||||
private static JsonReader CreateAnotherReader(JObject jObject, JsonReader reader)
|
||||
{
|
||||
var jObjectReader = jObject.CreateReader();
|
||||
jObjectReader.Culture = reader.Culture;
|
||||
jObjectReader.CloseInput = reader.CloseInput;
|
||||
jObjectReader.SupportMultipleContent = reader.SupportMultipleContent;
|
||||
jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling;
|
||||
jObjectReader.FloatParseHandling = reader.FloatParseHandling;
|
||||
jObjectReader.DateFormatString = reader.DateFormatString;
|
||||
jObjectReader.DateParseHandling = reader.DateParseHandling;
|
||||
return jObjectReader;
|
||||
}
|
||||
|
||||
public Type GetType(JObject jObject, Type parentType)
|
||||
{
|
||||
if (_typeMappingPropertyName == null)
|
||||
{
|
||||
return GetTypeByPropertyPresence(jObject, parentType);
|
||||
}
|
||||
return GetTypeFromDiscriminatorValue(jObject, parentType);
|
||||
}
|
||||
|
||||
private static Type GetTypeByPropertyPresence(JObject jObject, Type parentType)
|
||||
{
|
||||
foreach (var type in parentType.GetTypeInfo().GetCustomAttributes<KnownSubTypeWithPropertyAttribute>())
|
||||
{
|
||||
JToken ignore;
|
||||
if (jObject.TryGetValue(type.PropertyName, out ignore))
|
||||
{
|
||||
return type.SubType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Type GetTypeFromDiscriminatorValue(JObject jObject, Type parentType)
|
||||
{
|
||||
JToken jToken;
|
||||
if (!jObject.TryGetValue(_typeMappingPropertyName, out jToken)) return null;
|
||||
|
||||
var discriminatorValue = jToken.ToObject<object>();
|
||||
if (discriminatorValue == null) return null;
|
||||
|
||||
var typeMapping = GetSubTypeMapping(parentType);
|
||||
if (typeMapping.Any())
|
||||
{
|
||||
return GetTypeFromMapping(typeMapping, discriminatorValue);
|
||||
}
|
||||
return GetTypeByName(discriminatorValue as string, parentType);
|
||||
}
|
||||
|
||||
private static Type GetTypeByName(string typeName, Type parentType)
|
||||
{
|
||||
if (typeName == null)
|
||||
return null;
|
||||
|
||||
var insideAssembly = parentType.GetTypeInfo().Assembly;
|
||||
|
||||
var typeByName = insideAssembly.GetType(typeName);
|
||||
if (typeByName == null)
|
||||
{
|
||||
var searchLocation = parentType.FullName.Substring(0, parentType.FullName.Length - parentType.Name.Length);
|
||||
typeByName = insideAssembly.GetType(searchLocation + typeName, false, true);
|
||||
}
|
||||
return typeByName;
|
||||
}
|
||||
|
||||
private static Type GetTypeFromMapping(IReadOnlyDictionary<object, Type> typeMapping, object discriminatorValue)
|
||||
{
|
||||
var targetlookupValueType = typeMapping.First().Key.GetType();
|
||||
var lookupValue = ConvertJsonValueToType(discriminatorValue, targetlookupValueType);
|
||||
|
||||
Type targetType;
|
||||
return typeMapping.TryGetValue(lookupValue, out targetType) ? targetType : null;
|
||||
}
|
||||
|
||||
private static Dictionary<object, Type> GetSubTypeMapping(Type type)
|
||||
{
|
||||
return type.GetTypeInfo().GetCustomAttributes<KnownSubTypeAttribute>().ToDictionary(x => x.AssociatedValue, x => x.SubType);
|
||||
}
|
||||
|
||||
private static object ConvertJsonValueToType(object objectType, Type targetlookupValueType)
|
||||
{
|
||||
if (targetlookupValueType.GetTypeInfo().IsEnum)
|
||||
return Enum.ToObject(targetlookupValueType, objectType);
|
||||
|
||||
return Convert.ChangeType(objectType, targetlookupValueType);
|
||||
}
|
||||
|
||||
protected object _ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
_reader = reader;
|
||||
_isInsideRead = true;
|
||||
try
|
||||
{
|
||||
return serializer.Deserialize(reader, objectType);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isInsideRead = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,13 +99,13 @@ namespace IO.Swagger.Model
|
||||
return
|
||||
(
|
||||
this.MapProperty == input.MapProperty ||
|
||||
(this.MapProperty != null &&
|
||||
this.MapProperty.SequenceEqual(input.MapProperty))
|
||||
this.MapProperty != null &&
|
||||
this.MapProperty.SequenceEqual(input.MapProperty)
|
||||
) &&
|
||||
(
|
||||
this.MapOfMapProperty == input.MapOfMapProperty ||
|
||||
(this.MapOfMapProperty != null &&
|
||||
this.MapOfMapProperty.SequenceEqual(input.MapOfMapProperty))
|
||||
this.MapOfMapProperty != null &&
|
||||
this.MapOfMapProperty.SequenceEqual(input.MapOfMapProperty)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using JsonSubTypes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
|
||||
|
||||
@@ -28,6 +29,9 @@ namespace IO.Swagger.Model
|
||||
/// Animal
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonConverter(typeof(JsonSubtypes), "className")]
|
||||
[JsonSubtypes.KnownSubType(typeof(Dog), "Dog")]
|
||||
[JsonSubtypes.KnownSubType(typeof(Cat), "Cat")]
|
||||
public partial class Animal : IEquatable<Animal>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
@@ -92,7 +96,7 @@ namespace IO.Swagger.Model
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public string ToJson()
|
||||
public virtual string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
@@ -153,6 +157,16 @@ namespace IO.Swagger.Model
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
return this.BaseValidate(validationContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
protected IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> BaseValidate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace IO.Swagger.Model
|
||||
/// Initializes a new instance of the <see cref="AnimalFarm" /> class.
|
||||
/// </summary>
|
||||
[JsonConstructorAttribute]
|
||||
public AnimalFarm()
|
||||
public AnimalFarm() : base()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class AnimalFarm {\n");
|
||||
sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
@@ -54,7 +55,7 @@ namespace IO.Swagger.Model
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public new string ToJson()
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
@@ -79,7 +80,7 @@ namespace IO.Swagger.Model
|
||||
if (input == null)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
return base.Equals(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +91,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hashCode = 41;
|
||||
int hashCode = base.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace IO.Swagger.Model
|
||||
return
|
||||
(
|
||||
this.ArrayArrayNumber == input.ArrayArrayNumber ||
|
||||
(this.ArrayArrayNumber != null &&
|
||||
this.ArrayArrayNumber.SequenceEqual(input.ArrayArrayNumber))
|
||||
this.ArrayArrayNumber != null &&
|
||||
this.ArrayArrayNumber.SequenceEqual(input.ArrayArrayNumber)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace IO.Swagger.Model
|
||||
return
|
||||
(
|
||||
this.ArrayNumber == input.ArrayNumber ||
|
||||
(this.ArrayNumber != null &&
|
||||
this.ArrayNumber.SequenceEqual(input.ArrayNumber))
|
||||
this.ArrayNumber != null &&
|
||||
this.ArrayNumber.SequenceEqual(input.ArrayNumber)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,18 +108,18 @@ namespace IO.Swagger.Model
|
||||
return
|
||||
(
|
||||
this.ArrayOfString == input.ArrayOfString ||
|
||||
(this.ArrayOfString != null &&
|
||||
this.ArrayOfString.SequenceEqual(input.ArrayOfString))
|
||||
this.ArrayOfString != null &&
|
||||
this.ArrayOfString.SequenceEqual(input.ArrayOfString)
|
||||
) &&
|
||||
(
|
||||
this.ArrayArrayOfInteger == input.ArrayArrayOfInteger ||
|
||||
(this.ArrayArrayOfInteger != null &&
|
||||
this.ArrayArrayOfInteger.SequenceEqual(input.ArrayArrayOfInteger))
|
||||
this.ArrayArrayOfInteger != null &&
|
||||
this.ArrayArrayOfInteger.SequenceEqual(input.ArrayArrayOfInteger)
|
||||
) &&
|
||||
(
|
||||
this.ArrayArrayOfModel == input.ArrayArrayOfModel ||
|
||||
(this.ArrayArrayOfModel != null &&
|
||||
this.ArrayArrayOfModel.SequenceEqual(input.ArrayArrayOfModel))
|
||||
this.ArrayArrayOfModel != null &&
|
||||
this.ArrayArrayOfModel.SequenceEqual(input.ArrayArrayOfModel)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,44 +38,12 @@ namespace IO.Swagger.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Cat" /> class.
|
||||
/// </summary>
|
||||
/// <param name="ClassName">ClassName (required).</param>
|
||||
/// <param name="Color">Color (default to "red").</param>
|
||||
/// <param name="Declawed">Declawed.</param>
|
||||
public Cat(string ClassName = default(string), string Color = "red", bool? Declawed = default(bool?))
|
||||
public Cat(bool? Declawed = default(bool?), string ClassName = "Cat", string Color = "red") : base(ClassName, Color)
|
||||
{
|
||||
// to ensure "ClassName" is required (not null)
|
||||
if (ClassName == null)
|
||||
{
|
||||
throw new InvalidDataException("ClassName is a required property for Cat and cannot be null");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ClassName = ClassName;
|
||||
}
|
||||
// use default value if no "Color" provided
|
||||
if (Color == null)
|
||||
{
|
||||
this.Color = "red";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Color = Color;
|
||||
}
|
||||
this.Declawed = Declawed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ClassName
|
||||
/// </summary>
|
||||
[DataMember(Name="className", EmitDefaultValue=false)]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Color
|
||||
/// </summary>
|
||||
[DataMember(Name="color", EmitDefaultValue=false)]
|
||||
public string Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Declawed
|
||||
/// </summary>
|
||||
@@ -90,8 +58,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Cat {\n");
|
||||
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
|
||||
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
@@ -101,7 +68,7 @@ namespace IO.Swagger.Model
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public new string ToJson()
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
@@ -126,17 +93,7 @@ namespace IO.Swagger.Model
|
||||
if (input == null)
|
||||
return false;
|
||||
|
||||
return
|
||||
(
|
||||
this.ClassName == input.ClassName ||
|
||||
(this.ClassName != null &&
|
||||
this.ClassName.Equals(input.ClassName))
|
||||
) &&
|
||||
(
|
||||
this.Color == input.Color ||
|
||||
(this.Color != null &&
|
||||
this.Color.Equals(input.Color))
|
||||
) &&
|
||||
return base.Equals(input) &&
|
||||
(
|
||||
this.Declawed == input.Declawed ||
|
||||
(this.Declawed != null &&
|
||||
@@ -152,11 +109,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hashCode = 41;
|
||||
if (this.ClassName != null)
|
||||
hashCode = hashCode * 59 + this.ClassName.GetHashCode();
|
||||
if (this.Color != null)
|
||||
hashCode = hashCode * 59 + this.Color.GetHashCode();
|
||||
int hashCode = base.GetHashCode();
|
||||
if (this.Declawed != null)
|
||||
hashCode = hashCode * 59 + this.Declawed.GetHashCode();
|
||||
return hashCode;
|
||||
@@ -170,6 +123,7 @@ namespace IO.Swagger.Model
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
foreach(var x in BaseValidate(validationContext)) yield return x;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,44 +38,12 @@ namespace IO.Swagger.Model
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Dog" /> class.
|
||||
/// </summary>
|
||||
/// <param name="ClassName">ClassName (required).</param>
|
||||
/// <param name="Color">Color (default to "red").</param>
|
||||
/// <param name="Breed">Breed.</param>
|
||||
public Dog(string ClassName = default(string), string Color = "red", string Breed = default(string))
|
||||
public Dog(string Breed = default(string), string ClassName = "Dog", string Color = "red") : base(ClassName, Color)
|
||||
{
|
||||
// to ensure "ClassName" is required (not null)
|
||||
if (ClassName == null)
|
||||
{
|
||||
throw new InvalidDataException("ClassName is a required property for Dog and cannot be null");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ClassName = ClassName;
|
||||
}
|
||||
// use default value if no "Color" provided
|
||||
if (Color == null)
|
||||
{
|
||||
this.Color = "red";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Color = Color;
|
||||
}
|
||||
this.Breed = Breed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ClassName
|
||||
/// </summary>
|
||||
[DataMember(Name="className", EmitDefaultValue=false)]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Color
|
||||
/// </summary>
|
||||
[DataMember(Name="color", EmitDefaultValue=false)]
|
||||
public string Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Breed
|
||||
/// </summary>
|
||||
@@ -90,8 +58,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Dog {\n");
|
||||
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
|
||||
sb.Append(" Breed: ").Append(Breed).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
@@ -101,7 +68,7 @@ namespace IO.Swagger.Model
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public new string ToJson()
|
||||
public override string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
@@ -126,17 +93,7 @@ namespace IO.Swagger.Model
|
||||
if (input == null)
|
||||
return false;
|
||||
|
||||
return
|
||||
(
|
||||
this.ClassName == input.ClassName ||
|
||||
(this.ClassName != null &&
|
||||
this.ClassName.Equals(input.ClassName))
|
||||
) &&
|
||||
(
|
||||
this.Color == input.Color ||
|
||||
(this.Color != null &&
|
||||
this.Color.Equals(input.Color))
|
||||
) &&
|
||||
return base.Equals(input) &&
|
||||
(
|
||||
this.Breed == input.Breed ||
|
||||
(this.Breed != null &&
|
||||
@@ -152,11 +109,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hashCode = 41;
|
||||
if (this.ClassName != null)
|
||||
hashCode = hashCode * 59 + this.ClassName.GetHashCode();
|
||||
if (this.Color != null)
|
||||
hashCode = hashCode * 59 + this.Color.GetHashCode();
|
||||
int hashCode = base.GetHashCode();
|
||||
if (this.Breed != null)
|
||||
hashCode = hashCode * 59 + this.Breed.GetHashCode();
|
||||
return hashCode;
|
||||
@@ -170,6 +123,7 @@ namespace IO.Swagger.Model
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
foreach(var x in BaseValidate(validationContext)) yield return x;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ namespace IO.Swagger.Model
|
||||
) &&
|
||||
(
|
||||
this.ArrayEnum == input.ArrayEnum ||
|
||||
(this.ArrayEnum != null &&
|
||||
this.ArrayEnum.SequenceEqual(input.ArrayEnum))
|
||||
this.ArrayEnum != null &&
|
||||
this.ArrayEnum.SequenceEqual(input.ArrayEnum)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,13 +120,13 @@ namespace IO.Swagger.Model
|
||||
return
|
||||
(
|
||||
this.MapMapOfString == input.MapMapOfString ||
|
||||
(this.MapMapOfString != null &&
|
||||
this.MapMapOfString.SequenceEqual(input.MapMapOfString))
|
||||
this.MapMapOfString != null &&
|
||||
this.MapMapOfString.SequenceEqual(input.MapMapOfString)
|
||||
) &&
|
||||
(
|
||||
this.MapOfEnumString == input.MapOfEnumString ||
|
||||
(this.MapOfEnumString != null &&
|
||||
this.MapOfEnumString.SequenceEqual(input.MapOfEnumString))
|
||||
this.MapOfEnumString != null &&
|
||||
this.MapOfEnumString.SequenceEqual(input.MapOfEnumString)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,8 +118,8 @@ namespace IO.Swagger.Model
|
||||
) &&
|
||||
(
|
||||
this.Map == input.Map ||
|
||||
(this.Map != null &&
|
||||
this.Map.SequenceEqual(input.Map))
|
||||
this.Map != null &&
|
||||
this.Map.SequenceEqual(input.Map)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,13 +199,13 @@ namespace IO.Swagger.Model
|
||||
) &&
|
||||
(
|
||||
this.PhotoUrls == input.PhotoUrls ||
|
||||
(this.PhotoUrls != null &&
|
||||
this.PhotoUrls.SequenceEqual(input.PhotoUrls))
|
||||
this.PhotoUrls != null &&
|
||||
this.PhotoUrls.SequenceEqual(input.PhotoUrls)
|
||||
) &&
|
||||
(
|
||||
this.Tags == input.Tags ||
|
||||
(this.Tags != null &&
|
||||
this.Tags.SequenceEqual(input.Tags))
|
||||
this.Tags != null &&
|
||||
this.Tags.SequenceEqual(input.Tags)
|
||||
) &&
|
||||
(
|
||||
this.Status == input.Status ||
|
||||
|
||||
Reference in New Issue
Block a user