All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp-functions.AbstractOpenAPISchema.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{>partial_header}}

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace {{packageName}}.{{modelPackage}}
{
    /// 
    ///  Abstract base class for oneOf, anyOf schemas in the OpenAPI specification
    /// 
    {{>visibility}} abstract partial class AbstractOpenAPISchema
    {
        /// 
        ///  Custom JSON serializer
        /// 
        static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
        {
            // OpenAPI generated types generally hide default constructors.
            ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
            MissingMemberHandling = MissingMemberHandling.Error,
            ContractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy
                {
                    OverrideSpecifiedNames = false
                }
            }
        };

        /// 
        ///  Custom JSON serializer for objects with additional properties
        /// 
        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
                }
            }
        };

        /// 
        /// Gets or Sets the actual instance
        /// 
        public abstract Object ActualInstance { get; set; }

        /// 
        /// Gets or Sets IsNullable to indicate whether the instance is nullable
        /// 
        public bool IsNullable { get; protected set; }

        /// 
        /// Gets or Sets the schema type, which can be either `oneOf` or `anyOf`
        /// 
        public string SchemaType { get; protected set; }

        /// 
        /// Converts the instance into JSON string.
        /// 
        public abstract string ToJson();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy