    /// <summary>
    /// A Json converter for type {{classname}}
    /// </summary>
    {{>visibility}} class {{classname}}JsonConverter : JsonConverter<{{classname}}>
    {
        /// <summary>
        /// A Json reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="typeToConvert"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        /// <exception cref="JsonException"></exception>
        public override {{classname}} Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            int currentDepth = reader.CurrentDepth;

            if (reader.TokenType != JsonTokenType.StartObject && reader.TokenType != JsonTokenType.StartArray)
                throw new JsonException();

            JsonTokenType startingTokenType = reader.TokenType;

            {{#composedSchemas.anyOf}}
            Utf8JsonReader {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Reader = reader;
            bool {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Deserialized = Client.ClientUtils.TryDeserialize<{{{dataType}}}>(ref {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Reader, options, out {{{dataType}}}{{^isBoolean}}{{nrt?}}{{/isBoolean}} {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}});

            {{/composedSchemas.anyOf}}
            {{#composedSchemas.oneOf}}
            Utf8JsonReader {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Reader = reader;
            bool {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Deserialized = Client.ClientUtils.TryDeserialize<{{{dataType}}}>(ref {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Reader, options, out {{{dataType}}}{{^isBoolean}}{{nrt?}}{{/isBoolean}} {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}});

            {{/composedSchemas.oneOf}}
            {{#composedSchemas.allOf}}
            {{^isInherited}}
            Utf8JsonReader {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Reader = reader;
            bool {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Deserialized = Client.ClientUtils.TryDeserialize<{{{dataType}}}>(ref reader, options, out {{{dataType}}}{{^isBoolean}}{{nrt?}}{{/isBoolean}} {{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}});

            {{/isInherited}}
            {{/composedSchemas.allOf}}
            {{#allVars}}
            {{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{#isEnum}}{{#isNullable}}?{{/isNullable}}{{/isEnum}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default;
            {{/allVars}}

            while (reader.Read())
            {
                if (startingTokenType == JsonTokenType.StartObject && reader.TokenType == JsonTokenType.EndObject && currentDepth == reader.CurrentDepth)
                    break;

                if (startingTokenType == JsonTokenType.StartArray && reader.TokenType == JsonTokenType.EndArray && currentDepth == reader.CurrentDepth)
                    break;

                if (reader.TokenType == JsonTokenType.PropertyName && currentDepth == reader.CurrentDepth - 1)
                {
                    string{{nrt?}} propertyName = reader.GetString();
                    reader.Read();

                    switch (propertyName)
                    {
                        {{#allVars}}
                        case "{{baseName}}":
                        {{#isString}}
                        {{^isMap}}
                        {{^isEnum}}
                        {{^isUuid}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetString();
                        {{/isUuid}}
                        {{/isEnum}}
                        {{/isMap}}
                        {{/isString}}
                        {{#isBoolean}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetBoolean();
                        {{/isBoolean}}
                        {{#isNumeric}}
                        {{^isEnum}}
                        {{#isDouble}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetDouble();
                        {{/isDouble}}
                        {{#isDecimal}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetDecimal();
                        {{/isDecimal}}
                        {{#isFloat}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = (float)reader.GetDouble();
                        {{/isFloat}}
                        {{#isLong}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetInt64();
                        {{/isLong}}
                        {{^isLong}}
                        {{^isFloat}}
                        {{^isDecimal}}
                        {{^isDouble}}
                        {{#isNullable}}
                            if (reader.TokenType != JsonTokenType.Null)
                                {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetInt32();
                        {{/isNullable}}
                        {{^isNullable}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetInt32();
                        {{/isNullable}}
                        {{/isDouble}}
                        {{/isDecimal}}
                        {{/isFloat}}
                        {{/isLong}}
                        {{/isEnum}}
                        {{/isNumeric}}
                        {{#isDate}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref reader, options);
                        {{/isDate}}
                        {{#isDateTime}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref reader, options);
                        {{/isDateTime}}
                        {{#isEnum}}
                        {{^isMap}}
                        {{#isNumeric}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = ({{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}) reader.GetInt32();
                        {{/isNumeric}}
                        {{^isNumeric}}
                            string {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = reader.GetString();
                            {{^isInnerEnum}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{{datatypeWithEnum}}}Converter.FromString{{#isNullable}}OrDefault{{/isNullable}}({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
                            {{/isInnerEnum}}
                            {{#isInnerEnum}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{classname}}.{{{datatypeWithEnum}}}FromString({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
                            {{/isInnerEnum}}
                        {{/isNumeric}}
                        {{/isMap}}
                        {{/isEnum}}
                        {{#isUuid}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = reader.GetGuid();
                        {{/isUuid}}
                        {{^isUuid}}
                        {{^isEnum}}
                        {{^isString}}
                        {{^isBoolean}}
                        {{^isNumeric}}
                        {{^isDate}}
                        {{^isDateTime}}
                            {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<{{{datatypeWithEnum}}}>(ref reader, options);
                        {{/isDateTime}}
                        {{/isDate}}
                        {{/isNumeric}}
                        {{/isBoolean}}
                        {{/isString}}
                        {{/isEnum}}
                        {{/isUuid}}
                            break;
                        {{/allVars}}
                        default:
                            break;
                    }
                }
            }

            {{#composedSchemas.oneOf}}
            if ({{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}Deserialized)
                return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}  {{#model.composedSchemas.allOf}}{{^isInherited}}{{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}{{/isInherited}}{{/model.composedSchemas.allOf}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}  {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}  {{/allVars}}{{/lambda.joinWithComma}});

            {{#-last}}
            throw new JsonException();
            {{/-last}}
            {{/composedSchemas.oneOf}}
            {{^composedSchemas.oneOf}}
            return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}  {{/model.composedSchemas.anyOf}}{{#model.composedSchemas.allOf}}{{^isInherited}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}  {{/isInherited}}{{/model.composedSchemas.allOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}  {{/allVars}}{{/lambda.joinWithComma}});
            {{/composedSchemas.oneOf}}
        }

        /// <summary>
        /// A Json writer
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}"></param>
        /// <param name="options"></param>
        /// <exception cref="NotImplementedException"></exception>
        public override void Write(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}, JsonSerializerOptions options)
        {
            writer.WriteStartObject();

            {{#allVars}}
            {{#isString}}
            {{^isMap}}
            {{^isEnum}}
            {{^isUuid}}
            writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
            {{/isUuid}}
            {{/isEnum}}
            {{/isMap}}
            {{/isString}}
            {{#isBoolean}}
            {{#isNullable}}
            if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
                writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value);
            else
                writer.WriteNull("{{baseName}}");
            {{/isNullable}}
            {{^isNullable}}
            writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
            {{/isNullable}}
            {{/isBoolean}}
            {{^isEnum}}
            {{#isNumeric}}
            {{#isNullable}}
            if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
                writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value);
            else
                writer.WriteNull("{{baseName}}");
            {{/isNullable}}
            {{^isNullable}}
            writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
            {{/isNullable}}
            {{/isNumeric}}
            {{/isEnum}}
            {{#isDate}}
            writer.WritePropertyName("{{baseName}}");
            JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, options);
            {{/isDate}}
            {{#isDateTime}}
            writer.WritePropertyName("{{baseName}}");
            JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, options);
            {{/isDateTime}}
            {{#isEnum}}
            {{#isNumeric}}
            writer.WriteNumber("{{baseName}}", {{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}));
            {{/isNumeric}}
            {{^isMap}}
            {{^isNumeric}}
            {{#isInnerEnum}}
            var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
            if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null)
                writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
            else
                writer.WriteNull("{{baseName}}");
            {{/isInnerEnum}}
            {{^isInnerEnum}}
            {{#isNullable}}
            if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null)
                writer.WriteNull("{{baseName}}");
            {{/isNullable}}
            var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}Converter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{#isNullable}}.Value{{/isNullable}});
            if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null)
                writer.Write{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}String{{/isString}}{{^isString}}Number{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}("{{baseName}}", {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
            else
                writer.WriteNull("{{baseName}}");
            {{/isInnerEnum}}
            {{/isNumeric}}
            {{/isMap}}
            {{/isEnum}}
            {{#isUuid}}
            writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
            {{/isUuid}}
            {{^isUuid}}
            {{^isEnum}}
            {{^isString}}
            {{^isBoolean}}
            {{^isNumeric}}
            {{^isDate}}
            {{^isDateTime}}
            writer.WritePropertyName("{{baseName}}");
            JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, options);
            {{/isDateTime}}
            {{/isDate}}
            {{/isNumeric}}
            {{/isBoolean}}
            {{/isString}}
            {{/isEnum}}
            {{/isUuid}}
            {{/allVars}}

            writer.WriteEndObject();
        }
    }