// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version: 18.0.0.0
//  
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace Azure.Iot.Operations.Opc2WotLib
{
    using System.Collections.Generic;
    using System.Linq;
    using System;
    
    /// <summary>
    /// Class to produce the template output
    /// </summary>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "18.0.0.0")]
    public partial class WotDataSchemaObject : WotDataSchema
    {
        /// <summary>
        /// Create the template output
        /// </summary>
        public override string TransformText()
        {
 // Copyright (c) Microsoft Corporation. 
 // Licensed under the MIT License 
 if (this.schemaName != null) { 
            this.Write("\"title\": \"");
            this.Write(this.ToStringHelper.ToStringWithCulture(this.schemaName));
            this.Write("\",\r\n");
 } 
 if (this.description != null) { 
            this.Write("\"description\": \"");
            this.Write(this.ToStringHelper.ToStringWithCulture(this.description));
            this.Write("\",\r\n");
 } 
            this.Write("\"type\": \"object\",\r\n\"dov:typeRef\": \"");
            this.Write(this.ToStringHelper.ToStringWithCulture(this.typeRef));
            this.Write("\",\r\n");
 if (this.requiredFieldNames.Any()) { 
            this.Write("\"required\": [ ");
            this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(", ", this.requiredFieldNames.Select(f => $"\"{f}\""))));
            this.Write(" ],\r\n");
 } 
            this.Write("\"properties\": {\r\n");
 int ix = 1; foreach (KeyValuePair<string, WotDataSchema> fieldDataSchema in this.fieldDataSchemas) { 
            this.Write("  \"");
            this.Write(this.ToStringHelper.ToStringWithCulture(fieldDataSchema.Key));
            this.Write("\": {\r\n");
 this.PushIndent("    "); 
            this.Write(this.ToStringHelper.ToStringWithCulture(fieldDataSchema.Value.TransformText()));
            this.Write("\r\n");
 this.PopIndent(); 
            this.Write("  }");
            this.Write(this.ToStringHelper.ToStringWithCulture(ix < this.fieldDataSchemas.Count ? "," : ""));
            this.Write("\r\n");
 ix++; } 
            this.Write("}");
            return this.GenerationEnvironment.ToString();
        }
    }
}
