private static Property ConvertGeneratorParamToProperty(GeneratorParameter p)
		{
			return new Property
			       {
				       Name = NetNamingMapper.Capitalize(p.Name),
                       OriginalName = p.Name,
				       Description = p.Description,
				       Type = p.Type,
				       Required = true
			       };
		}
        private GeneratorParameter GetParameterByParametrizedName(Method method, Resource resource, string schema, string fullUrl)
        {
            GeneratorParameter generatorParameter = null;
            var type = schemaParameterParser.Parse(schema, resource, method, fullUrl);

            if (schemaObjects.Values.Any(o => o.Name.ToLower() == type.ToLowerInvariant()))
            {
                var apiObject = schemaObjects.Values.First(o => o.Name.ToLower() == type.ToLowerInvariant());
                generatorParameter = CreateGeneratorParameter(apiObject);
            }

            if (schemaRequestObjects.Values.Any(o => o.Name.ToLower() == type.ToLowerInvariant()))
            {
                var apiObject = schemaRequestObjects.Values.First(o => o.Name.ToLower() == type.ToLowerInvariant());
                generatorParameter = CreateGeneratorParameter(apiObject);
            }
            return(generatorParameter);
        }
        private GeneratorParameter GetParameterByParametrizedName(Method method, Resource resource,
                                                                  IDictionary <string, ApiObject> schemaRequestObjects, string schema)
        {
            GeneratorParameter generatorParameter = null;
            var type = schemaParameterParser.Parse(schema, resource, method);

            if (schemaRequestObjects.Values.Any(o => o.Properties.Any() && o.Name.ToLower() == type))
            {
                var apiObject = schemaRequestObjects.Values.First(o => o.Properties.Any() && o.Name.ToLower() == type);
                generatorParameter = new GeneratorParameter
                {
                    Name        = apiObject.Name.ToLower(),
                    Type        = apiObject.IsArray ? apiObject.Name + "[]" : apiObject.Name,
                    Description = apiObject.Description
                };
            }
            return(generatorParameter);
        }
        private static GeneratorParameter GetParameterByName(IDictionary <string, ApiObject> schemaRequestObjects, string schema)
        {
            GeneratorParameter generatorParameter = null;

            var type = schema.ToLowerInvariant();

            if (schemaRequestObjects.Values.Any(o => o.Properties.Any() && o.Name.ToLowerInvariant() == type))
            {
                var apiObject = schemaRequestObjects.Values.First(o => o.Properties.Any() && o.Name.ToLowerInvariant() == type);
                generatorParameter = new GeneratorParameter
                {
                    Name        = apiObject.Name.ToLower(),
                    Type        = apiObject.IsArray ? apiObject.Name + "[]" : apiObject.Name,
                    Description = apiObject.Description
                };
            }
            return(generatorParameter);
        }
        private GeneratorParameter GetParameterByName(string schema)
        {
            GeneratorParameter generatorParameter = null;

            var type = schema.ToLowerInvariant();

            if (schemaObjects.Values.Any(o => o.Name.ToLowerInvariant() == type))
            {
                var apiObject = schemaObjects.Values.First(o => o.Name.ToLowerInvariant() == type);
                generatorParameter = CreateGeneratorParameter(apiObject);
            }

            if (schemaRequestObjects.Values.Any(o => o.Name.ToLowerInvariant() == type))
            {
                var apiObject = schemaRequestObjects.Values.First(o => o.Name.ToLowerInvariant() == type);
                generatorParameter = CreateGeneratorParameter(apiObject);
            }
            return(generatorParameter);
        }
 private static GeneratorParameter CreateGeneratorParameter(ApiObject apiObject)
 {
     var generatorParameter = new GeneratorParameter
     {
         Name = apiObject.Name.ToLower(),
         Type = GetTypeFromApiObject(apiObject),
         Description = apiObject.Description
     };
     return generatorParameter;
 }
		private GeneratorParameter GetParameterByParametrizedName(Method method, Resource resource, string schema, string fullUrl)
		{
			GeneratorParameter generatorParameter = null;
			var type = schemaParameterParser.Parse(schema, resource, method, fullUrl);
			if (schemaRequestObjects.Values.Any(o => o.Properties.Any() && o.Name.ToLower() == type.ToLowerInvariant()))
			{
				var apiObject = schemaRequestObjects.Values.First(o => o.Properties.Any() && o.Name.ToLower() == type.ToLowerInvariant());
				generatorParameter = new GeneratorParameter
				                     {
					                     Name = apiObject.Name.ToLower(),
                                         Type = apiObject.IsArray ? CollectionTypeHelper.GetCollectionType(apiObject.Name) : apiObject.Name,
					                     Description = apiObject.Description
				                     };
			}
			return generatorParameter;
		}
		private GeneratorParameter GetParameterByName(string schema)
		{
			GeneratorParameter generatorParameter = null;

			var type = schema.ToLowerInvariant();
			if (schemaRequestObjects.Values.Any(o => o.Properties.Any() && o.Name.ToLowerInvariant() == type))
			{
				var apiObject = schemaRequestObjects.Values.First(o => o.Properties.Any() && o.Name.ToLowerInvariant() == type);
				generatorParameter = new GeneratorParameter
				                     {
					                     Name = apiObject.Name.ToLower(),
                                         Type = apiObject.IsArray ? CollectionTypeHelper.GetCollectionType(apiObject.Name) : apiObject.Name,
					                     Description = apiObject.Description
				                     };
			}
			return generatorParameter;
		}
        public GeneratorParameter GetRequestParameter(string key, Method method, Resource resource, string fullUrl, string defaultMediaType)
        {
            var mimeType = GetMimeType(method.Body, defaultMediaType);

            if (mimeType != null)
            {
                if (mimeType.Type != "object" && !string.IsNullOrWhiteSpace(mimeType.Type))
                {
                    var apiObject = GetRequestApiObjectWhenNamed(method, resource, mimeType.Type, fullUrl);
                    if (apiObject != null)
                    {
                        var generatorParameter = new GeneratorParameter
                        {
                            Name = apiObject.Name.ToLower(),
                            Type = GetParamType(mimeType, apiObject),
                            //Type = DecodeRequestRaml1Type(RamlTypesHelper.GetTypeFromApiObject(apiObject)),
                            Description = apiObject.Description
                        };
                        return(generatorParameter);
                    }
                }
                if (!string.IsNullOrWhiteSpace(mimeType.Schema))
                {
                    var apiObject = GetRequestApiObjectWhenNamed(method, resource, mimeType.Schema, fullUrl);
                    if (apiObject != null)
                    {
                        return(CreateGeneratorParameter(apiObject));
                    }
                }
            }

            if (resource.Type != null && resource.Type.Any() &&
                resourceTypes.Any(rt => rt.ContainsKey(resource.GetSingleType())))
            {
                var verb = RamlTypesHelper.GetResourceTypeVerb(method, resource, resourceTypes);
                if (verb != null && verb.Body != null && !string.IsNullOrWhiteSpace(verb.Body.Schema))
                {
                    var apiObject = GetRequestApiObjectWhenNamed(method, resource, verb.Body.Schema, fullUrl);
                    if (apiObject != null)
                    {
                        return(CreateGeneratorParameter(apiObject));
                    }
                }

                if (verb != null && verb.Body != null && !string.IsNullOrWhiteSpace(verb.Body.Type))
                {
                    var apiObject = GetRequestApiObjectWhenNamed(method, resource, verb.Body.Type, fullUrl);
                    if (apiObject != null)
                    {
                        var generatorParameter = new GeneratorParameter
                        {
                            Name        = apiObject.Name.ToLower(),
                            Type        = DecodeRequestRaml1Type(RamlTypesHelper.GetTypeFromApiObject(apiObject)),
                            Description = apiObject.Description
                        };
                        return(generatorParameter);
                    }

                    return(new GeneratorParameter {
                        Name = "content", Type = DecodeRequestRaml1Type(verb.Body.Type)
                    });
                }
            }

            var apiObjectByKey = GetRequestApiObjectByKey(key);

            if (apiObjectByKey != null)
            {
                return(CreateGeneratorParameter(apiObjectByKey));
            }


            var requestKey = key + GeneratorServiceBase.RequestContentSuffix;

            apiObjectByKey = GetRequestApiObjectByKey(requestKey);
            if (apiObjectByKey != null)
            {
                return(CreateGeneratorParameter(apiObjectByKey));
            }

            if (linkKeysWithObjectNames.ContainsKey(key))
            {
                var linkedKey = linkKeysWithObjectNames[key];
                apiObjectByKey = GetRequestApiObjectByKey(linkedKey);
                if (apiObjectByKey != null)
                {
                    return(CreateGeneratorParameter(apiObjectByKey));
                }
            }

            if (linkKeysWithObjectNames.ContainsKey(requestKey))
            {
                var linkedKey = linkKeysWithObjectNames[requestKey];
                apiObjectByKey = GetRequestApiObjectByKey(linkedKey);
                if (apiObjectByKey != null)
                {
                    return(CreateGeneratorParameter(apiObjectByKey));
                }
            }

            if (mimeType != null)
            {
                string type;
                if (!string.IsNullOrWhiteSpace(mimeType.Type))
                {
                    type = mimeType.Type;
                }
                else
                {
                    type = mimeType.Schema;
                }

                if (!string.IsNullOrWhiteSpace(type))
                {
                    var raml1Type = DecodeRequestRaml1Type(type);

                    if (!string.IsNullOrWhiteSpace(raml1Type))
                    {
                        return new GeneratorParameter {
                                   Name = "content", Type = raml1Type
                        }
                    }
                    ;
                }
            }

            return(new GeneratorParameter {
                Name = "content", Type = "string"
            });
        }
 private static GeneratorParameter CreateGeneratorParameter(ApiObject apiObject)
 {
     var generatorParameter = new GeneratorParameter
     {
         Name = apiObject.Name.ToLower(),
         Type = apiObject.IsArray ? CollectionTypeHelper.GetCollectionType(apiObject.Name) : apiObject.Name,
         Description = apiObject.Description
     };
     return generatorParameter;
 }
 private IEnumerable<GeneratorParameter> MatchParameters(IDictionary<string, Parameter> parentUriParameters, GeneratorParameter[] urlParameters)
 {
     var parameters = new List<GeneratorParameter>();
     foreach (var param in urlParameters)
     {
         if (parentUriParameters.ContainsKey(param.Name))
         {
             param.Type = NetTypeMapper.Map(parentUriParameters[param.Name].Type);
             param.Description = parentUriParameters[param.Name].Description;
         }
         parameters.Add(param);
     }
     return parameters;
 }