Example #1
0
        private void BuildOptionsParameterTemplateModel()
        {
            CompositeType optionsType;

            optionsType = new CompositeType
            {
                Name           = "options",
                SerializedName = "options",
                Documentation  = "Optional Parameters."
            };
            var optionsParmeter = new Parameter
            {
                Name           = "options",
                SerializedName = "options",
                IsRequired     = false,
                Documentation  = "Optional Parameters.",
                Location       = ParameterLocation.None,
                Type           = optionsType
            };

            IEnumerable <ParameterTemplateModel> optionalParameters = LocalParameters.Where(p => !p.IsRequired);

            foreach (ParameterTemplateModel parameter in optionalParameters)
            {
                Property optionalProperty = new Property
                {
                    IsReadOnly     = false,
                    Name           = parameter.Name,
                    IsRequired     = parameter.IsRequired,
                    DefaultValue   = parameter.DefaultValue,
                    Documentation  = parameter.Documentation,
                    Type           = parameter.Type,
                    SerializedName = parameter.SerializedName
                };
                parameter.Constraints.ToList().ForEach(x => optionalProperty.Constraints.Add(x.Key, x.Value));
                parameter.Extensions.ToList().ForEach(x => optionalProperty.Extensions.Add(x.Key, x.Value));
                ((CompositeType)optionsParmeter.Type).Properties.Add(optionalProperty);
            }

            //Adding customHeaders to the options object
            Property customHeaders = new Property
            {
                IsReadOnly     = false,
                Name           = "customHeaders",
                IsRequired     = false,
                Documentation  = "Headers that will be added to the request",
                Type           = new PrimaryType(KnownPrimaryType.Object),
                SerializedName = "customHeaders"
            };

            ((CompositeType)optionsParmeter.Type).Properties.Add(customHeaders);
            OptionsParameterTemplateModel = new ParameterTemplateModel(optionsParmeter);
        }
        private void BuildOptionsParameterTemplateModel()
        {
            CompositeType optionsType;
            optionsType = new CompositeType
            {
                Name = "options",
                SerializedName = "options",
                Documentation = "Optional Parameters."
            };
            var optionsParmeter = new Parameter
            {
                Name = "options",
                SerializedName = "options",
                IsRequired = false,
                Documentation = "Optional Parameters.",
                Location = ParameterLocation.None,
                Type = optionsType
            };

            IEnumerable<ParameterTemplateModel> optionalParameters = LocalParameters.Where(p => !p.IsRequired);
            foreach (ParameterTemplateModel parameter in optionalParameters)
            {
                Property optionalProperty = new Property
                {
                    IsReadOnly = false,
                    Name = parameter.Name,
                    IsRequired = parameter.IsRequired,
                    DefaultValue = parameter.DefaultValue,
                    Documentation = parameter.Documentation,
                    Type = parameter.Type,
                    SerializedName = parameter.SerializedName
                };
                parameter.Constraints.ToList().ForEach(x => optionalProperty.Constraints.Add(x.Key, x.Value));
                parameter.Extensions.ToList().ForEach(x => optionalProperty.Extensions.Add(x.Key, x.Value));
                ((CompositeType)optionsParmeter.Type).Properties.Add(optionalProperty);
            }

            //Adding customHeaders to the options object
            Property customHeaders = new Property
            {
                IsReadOnly = false,
                Name = "customHeaders",
                IsRequired = false,
                Documentation = "Headers that will be added to the request",
                Type = PrimaryType.Object,
                SerializedName = "customHeaders"
            };
            ((CompositeType)optionsParmeter.Type).Properties.Add(customHeaders);
            OptionsParameterTemplateModel = new ParameterTemplateModel(optionsParmeter);
        }