private string GetReturnTypeFromResourceType(Method method, Resource resource, string key, string responseCode, string fullUrl)
        {
            var returnType = string.Empty;

            if (resource.Type == null || !resource.Type.Any() ||
                !resourceTypes.Any(rt => rt.ContainsKey(resource.GetSingleType())))
            {
                return(returnType);
            }

            var verb = RamlTypesHelper.GetResourceTypeVerb(method, resource, resourceTypes);

            if (verb == null || verb.Responses == null ||
                !verb.Responses.Any(r => r != null && r.Body != null &&
                                    r.Body.Values.Any(m => !string.IsNullOrWhiteSpace(m.Schema) && !string.IsNullOrWhiteSpace(m.Type))))
            {
                return(returnType);
            }

            var response = verb.Responses.FirstOrDefault(r => r.Code == responseCode);

            if (response == null)
            {
                return(returnType);
            }

            var resourceTypeMimeType = GeneratorServiceHelper.GetMimeType(response);

            if (resourceTypeMimeType != null)
            {
                returnType = GetReturnTypeFromResponseWithoutCheckingResourceTypes(method, resource, resourceTypeMimeType, key, responseCode, fullUrl);
            }
            return(returnType);
        }
        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"
            });
        }