public static void SerializeCommonParameterProperties(StringBuilder sb, Parameter parameter, int indentation)
 {
     SerializeParameterProperty(sb, "default", parameter.Default, indentation + 2);
     SerializeDescriptionProperty(sb, parameter.Description, indentation + 2);
     SerializeParameterProperty(sb, "displayName", parameter.DisplayName, indentation + 2);
     SerializeParameterProperty(sb, "example", parameter.Example, indentation + 2);
     SerializeParameterProperty(sb, "pattern", parameter.Pattern, indentation + 2);
     SerializeParameterProperty(sb, "type", parameter.Type, indentation + 2);
     SerializeEnumProperty(sb, parameter.Enum, indentation + 2);
     SerializeParameterProperty(sb, "maxLength", parameter.MaxLength, indentation + 2);
     SerializeParameterProperty(sb, "maximum", parameter.Maximum, indentation + 2);
     SerializeParameterProperty(sb, "minimum", parameter.Minimum, indentation + 2);
     if (parameter.Repeat)
         SerializeParameterProperty(sb, "repeat", parameter.Repeat, indentation + 2);
 }
 public Parameter Build(IDictionary<string, object> dynamicRaml)
 {
     var parameter = new Parameter();
     parameter.Type = dynamicRaml.ContainsKey("type") ? (string) dynamicRaml["type"] : null;
     parameter.Required = dynamicRaml.ContainsKey("required") && (bool) dynamicRaml["required"];
     parameter.DisplayName = dynamicRaml.ContainsKey("displayName") ? (string) dynamicRaml["displayName"] : null;
     parameter.Description = dynamicRaml.ContainsKey("description") ? (string) dynamicRaml["description"] : null;
     parameter.Enum = GetEnum(dynamicRaml);
     parameter.Repeat = dynamicRaml.ContainsKey("repeat") && (bool) dynamicRaml["repeat"];
     parameter.Example = dynamicRaml.ContainsKey("example") ? dynamicRaml["example"].ToString() : null;
     parameter.Default = dynamicRaml.ContainsKey("default") ? (dynamicRaml["default"] != null ? dynamicRaml["default"].ToString() : null) : null;
     parameter.Pattern = dynamicRaml.ContainsKey("pattern") ? (string) dynamicRaml["pattern"] : null;
     parameter.MinLength = dynamicRaml.ContainsKey("minLength") ? Convert.ToInt32(dynamicRaml["default"]) : (int?) null;
     parameter.MaxLength = dynamicRaml.ContainsKey("maxLength") ? Convert.ToInt32(dynamicRaml["maxLength"]) : (int?) null;
     parameter.Minimum = dynamicRaml.ContainsKey("minimum") ? Convert.ToDecimal(dynamicRaml["minimum"]) : (decimal?) null;
     parameter.Maximum = dynamicRaml.ContainsKey("maximum") ? Convert.ToDecimal(dynamicRaml["maximum"]) : (decimal?) null;
     return parameter;
 }
		private static IDictionary<string, Parameter> GetParametersFromUrl(string url)
		{
			var dic = new Dictionary<string, Parameter>();

			if (string.IsNullOrWhiteSpace(url) || !url.Contains("{"))
				return dic;

			if (!url.Contains("{"))
				return dic;

			var regex = new Regex("{([^}]+)}");
			var matches = regex.Matches(url);
			foreach (Match match in matches)
			{
				var parameter = new Parameter {Required = true, Type = "string"};
				dic.Add(match.Groups[1].Value, parameter);
			}

			return dic;
		}
		private IDictionary<string, Parameter> GetQueryParameters(string urlWithParams, IEnumerable<ApiParameterDescription> parameterDescriptions)
		{
			var queryParams = new Dictionary<string, Parameter>();
			if (string.IsNullOrWhiteSpace(urlWithParams) || !urlWithParams.Contains("?"))
				return queryParams;

			var url = urlWithParams.Substring(urlWithParams.IndexOf("?", StringComparison.Ordinal));
			var urlParameters = GetParametersFromUrl(url);

			foreach (var apiParam in parameterDescriptions.Where(p => p.Source == ApiParameterSource.FromUri))
			{
				if (!urlParameters.ContainsKey(apiParam.Name)) 
					continue;

				var parameter = new Parameter
				                {
					                Default =
						                apiParam.ParameterDescriptor.DefaultValue == null
							                ? (apiParam.ParameterDescriptor.IsOptional ? "null" : null)
							                : apiParam.ParameterDescriptor.DefaultValue.ToString(),
					                Required = !apiParam.ParameterDescriptor.IsOptional,
					                Type = SchemaTypeMapper.Map(apiParam.ParameterDescriptor.ParameterType),
									Description = apiParam.Documentation
				                };
				if(!queryParams.ContainsKey(apiParam.Name))
					queryParams.Add(apiParam.Name, parameter);
			}
			return queryParams;
		}
 private static Parameter GetPrimitiveParameter(ApiParameterDescription apiParam)
 {
     var parameter = new Parameter
     {
         Default =
             apiParam.ParameterDescriptor.DefaultValue == null
                 ? (apiParam.ParameterDescriptor.IsOptional ? "null" : null)
                 : apiParam.ParameterDescriptor.DefaultValue.ToString(),
         Required = !apiParam.ParameterDescriptor.IsOptional,
         Type = SchemaTypeMapper.Map(apiParam.ParameterDescriptor.ParameterType),
         Description = apiParam.Documentation
     };
     return parameter;
 }
 private static Parameter GetParameterFromProperty(ApiParameterDescription apiParam, PropertyInfo property)
 {
     var parameter = new Parameter
     {
         Default = IsNullable(property.PropertyType) ? "null" : null,
         Required = !IsNullable(property.PropertyType),
         Type = SchemaTypeMapper.Map(property.PropertyType)
     };
     return parameter;
 }
 private static string GetType(Parameter param)
 {
     return param.Type == null ? "string" : (
         NetTypeMapper.Map(param.Type) +
         (NetTypeMapper.Map(param.Type) == "string" || param.Required ? "" : "?"));
 }
        public static void SerializeParameterProperties(StringBuilder sb, Parameter parameter, int indentation)
        {
            SerializeCommonParameterProperties(sb, parameter, indentation);

            SerializeParameterProperty(sb, "required", parameter.Required, indentation + 2);
        }