[csharp][generichost] Fixes de/serialization (#20540)

* fixed json serializer

* build samples
This commit is contained in:
devhl-labs
2025-01-26 09:18:11 -05:00
committed by GitHub
parent b033219c54
commit f1c1567aa9
186 changed files with 11210 additions and 2 deletions

View File

@@ -23,12 +23,14 @@ docs/Category.md
docs/ChildCat.md
docs/ClassModel.md
docs/ComplexQuadrilateral.md
docs/CopyActivity.md
docs/DanishPig.md
docs/DateOnlyClass.md
docs/DefaultApi.md
docs/DeprecatedObject.md
docs/Dog.md
docs/Drawing.md
docs/EntityBase.md
docs/EnumArrays.md
docs/EnumClass.md
docs/EnumTest.md
@@ -155,11 +157,13 @@ src/Org.OpenAPITools/Model/Category.cs
src/Org.OpenAPITools/Model/ChildCat.cs
src/Org.OpenAPITools/Model/ClassModel.cs
src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs
src/Org.OpenAPITools/Model/CopyActivity.cs
src/Org.OpenAPITools/Model/DanishPig.cs
src/Org.OpenAPITools/Model/DateOnlyClass.cs
src/Org.OpenAPITools/Model/DeprecatedObject.cs
src/Org.OpenAPITools/Model/Dog.cs
src/Org.OpenAPITools/Model/Drawing.cs
src/Org.OpenAPITools/Model/EntityBase.cs
src/Org.OpenAPITools/Model/EnumArrays.cs
src/Org.OpenAPITools/Model/EnumClass.cs
src/Org.OpenAPITools/Model/EnumTest.cs

View File

@@ -176,11 +176,13 @@ Class | Method | HTTP request | Description
- [Model.ChildCat](docs/ChildCat.md)
- [Model.ClassModel](docs/ClassModel.md)
- [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md)
- [Model.CopyActivity](docs/CopyActivity.md)
- [Model.DanishPig](docs/DanishPig.md)
- [Model.DateOnlyClass](docs/DateOnlyClass.md)
- [Model.DeprecatedObject](docs/DeprecatedObject.md)
- [Model.Dog](docs/Dog.md)
- [Model.Drawing](docs/Drawing.md)
- [Model.EntityBase](docs/EntityBase.md)
- [Model.EnumArrays](docs/EnumArrays.md)
- [Model.EnumClass](docs/EnumClass.md)
- [Model.EnumTest](docs/EnumTest.md)

View File

@@ -2872,6 +2872,31 @@ components:
uuid:
format: uuid
type: string
CopyActivity:
allOf:
- $ref: '#/components/schemas/EntityBase'
properties:
$schema:
enum:
- ScopeActivity
type: string
copyActivitytt:
type: string
required:
- $schema
- copyActivitytt
type: object
EntityBase:
discriminator:
mapping:
ScopeActivity: '#/components/schemas/CopyActivity'
propertyName: $schema
properties:
$schema:
type: string
required:
- $schema
type: object
_foo_get_default_response:
example:
string:

View File

@@ -0,0 +1,11 @@
# Org.OpenAPITools.Model.CopyActivity
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Schema** | **string** | | [default to SchemaEnum.ScopeActivity]
**CopyActivitytt** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,10 @@
# Org.OpenAPITools.Model.EntityBase
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Schema** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,75 @@
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using Xunit;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing CopyActivity
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class CopyActivityTests : IDisposable
{
// TODO uncomment below to declare an instance variable for CopyActivity
//private CopyActivity instance;
public CopyActivityTests()
{
// TODO uncomment below to create an instance of CopyActivity
//instance = new CopyActivity();
}
public void Dispose()
{
// Cleanup when everything is done.
}
/// <summary>
/// Test an instance of CopyActivity
/// </summary>
[Fact]
public void CopyActivityInstanceTest()
{
// TODO uncomment below to test "IsType" CopyActivity
//Assert.IsType<CopyActivity>(instance);
}
/// <summary>
/// Test the property 'Schema'
/// </summary>
[Fact]
public void SchemaTest()
{
// TODO unit test for the property 'Schema'
}
/// <summary>
/// Test the property 'CopyActivitytt'
/// </summary>
[Fact]
public void CopyActivityttTest()
{
// TODO unit test for the property 'CopyActivitytt'
}
}
}

View File

@@ -0,0 +1,76 @@
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using Xunit;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing EntityBase
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class EntityBaseTests : IDisposable
{
// TODO uncomment below to declare an instance variable for EntityBase
//private EntityBase instance;
public EntityBaseTests()
{
// TODO uncomment below to create an instance of EntityBase
//instance = new EntityBase();
}
public void Dispose()
{
// Cleanup when everything is done.
}
/// <summary>
/// Test an instance of EntityBase
/// </summary>
[Fact]
public void EntityBaseInstanceTest()
{
// TODO uncomment below to test "IsType" EntityBase
//Assert.IsType<EntityBase>(instance);
}
/// <summary>
/// Test deserialize a CopyActivity from type EntityBase
/// </summary>
[Fact]
public void CopyActivityDeserializeFromEntityBaseTest()
{
// TODO uncomment below to test deserialize a CopyActivity from type EntityBase
//Assert.IsType<EntityBase>(JsonConvert.DeserializeObject<EntityBase>(new CopyActivity().ToJson()));
}
/// <summary>
/// Test the property 'Schema'
/// </summary>
[Fact]
public void SchemaTest()
{
// TODO unit test for the property 'Schema'
}
}
}

View File

@@ -0,0 +1,222 @@
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using JsonSubTypes;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// CopyActivity
/// </summary>
[DataContract(Name = "CopyActivity")]
public partial class CopyActivity : EntityBase, IEquatable<CopyActivity>, IValidatableObject
{
/// <summary>
/// Defines Schema
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum SchemaEnum
{
/// <summary>
/// Enum ScopeActivity for value: ScopeActivity
/// </summary>
[EnumMember(Value = "ScopeActivity")]
ScopeActivity = 1
}
/// <summary>
/// Gets or Sets Schema
/// </summary>
[DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)]
public SchemaEnum Schema
{
get{ return _Schema;}
set
{
_Schema = value;
_flagSchema = true;
}
}
private SchemaEnum _Schema;
private bool _flagSchema;
/// <summary>
/// Returns false as Schema should not be serialized given that it's read-only.
/// </summary>
/// <returns>false (boolean)</returns>
public bool ShouldSerializeSchema()
{
return _flagSchema;
}
/// <summary>
/// Initializes a new instance of the <see cref="CopyActivity" /> class.
/// </summary>
[JsonConstructorAttribute]
protected CopyActivity()
{
this.AdditionalProperties = new Dictionary<string, object>();
}
/// <summary>
/// Initializes a new instance of the <see cref="CopyActivity" /> class.
/// </summary>
/// <param name="schema">schema (required) (default to SchemaEnum.ScopeActivity).</param>
/// <param name="copyActivitytt">copyActivitytt (required).</param>
public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base()
{
this._Schema = schema;
// to ensure "copyActivitytt" is required (not null)
if (copyActivitytt == null)
{
throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null");
}
this._CopyActivitytt = copyActivitytt;
this.AdditionalProperties = new Dictionary<string, object>();
}
/// <summary>
/// Gets or Sets CopyActivitytt
/// </summary>
[DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)]
public string CopyActivitytt
{
get{ return _CopyActivitytt;}
set
{
_CopyActivitytt = value;
_flagCopyActivitytt = true;
}
}
private string _CopyActivitytt;
private bool _flagCopyActivitytt;
/// <summary>
/// Returns false as CopyActivitytt should not be serialized given that it's read-only.
/// </summary>
/// <returns>false (boolean)</returns>
public bool ShouldSerializeCopyActivitytt()
{
return _flagCopyActivitytt;
}
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class CopyActivity {\n");
sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
sb.Append(" Schema: ").Append(Schema).Append("\n");
sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public override string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return OpenAPIClientUtils.compareLogic.Compare(this, input as CopyActivity).AreEqual;
}
/// <summary>
/// Returns true if CopyActivity instances are equal
/// </summary>
/// <param name="input">Instance of CopyActivity to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(CopyActivity input)
{
return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 59) + this.Schema.GetHashCode();
if (this.CopyActivitytt != null)
{
hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode();
}
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode;
}
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<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<ValidationResult> BaseValidate(ValidationContext validationContext)
{
foreach (var x in base.BaseValidate(validationContext))
{
yield return x;
}
yield break;
}
}
}

View File

@@ -0,0 +1,176 @@
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using JsonSubTypes;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// EntityBase
/// </summary>
[DataContract(Name = "EntityBase")]
[JsonConverter(typeof(JsonSubtypes), "Schema")]
[JsonSubtypes.KnownSubType(typeof(CopyActivity), "ScopeActivity")]
public partial class EntityBase : IEquatable<EntityBase>, IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="EntityBase" /> class.
/// </summary>
[JsonConstructorAttribute]
protected EntityBase()
{
this.AdditionalProperties = new Dictionary<string, object>();
}
/// <summary>
/// Initializes a new instance of the <see cref="EntityBase" /> class.
/// </summary>
/// <param name="schema">schema (required).</param>
public EntityBase(string schema = default(string))
{
// to ensure "schema" is required (not null)
if (schema == null)
{
throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null");
}
this._Schema = schema;
this.AdditionalProperties = new Dictionary<string, object>();
}
/// <summary>
/// Gets or Sets Schema
/// </summary>
[DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)]
public string Schema
{
get{ return _Schema;}
set
{
_Schema = value;
_flagSchema = true;
}
}
private string _Schema;
private bool _flagSchema;
/// <summary>
/// Returns false as Schema should not be serialized given that it's read-only.
/// </summary>
/// <returns>false (boolean)</returns>
public bool ShouldSerializeSchema()
{
return _flagSchema;
}
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class EntityBase {\n");
sb.Append(" Schema: ").Append(Schema).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return OpenAPIClientUtils.compareLogic.Compare(this, input as EntityBase).AreEqual;
}
/// <summary>
/// Returns true if EntityBase instances are equal
/// </summary>
/// <param name="input">Instance of EntityBase to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(EntityBase input)
{
return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.Schema != null)
{
hashCode = (hashCode * 59) + this.Schema.GetHashCode();
}
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode;
}
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<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<ValidationResult> BaseValidate(ValidationContext validationContext)
{
yield break;
}
}
}