Ejemplo n.º 1
0
        private MethodDescription FormateMethodDescription(RestPath restPath, Dictionary <string, SwaggerModel> models)
        {
            var verbs   = new List <string>();
            var summary = restPath.Summary;
            var notes   = restPath.Notes;

            if (restPath.AllowsAllVerbs)
            {
                verbs.AddRange(new[] { "GET", "POST", "PUT", "DELETE" });
            }
            else
            {
                verbs.AddRange(restPath.AllowedVerbs.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries));
            }

            var nickName = nicknameCleanerRegex.Replace(restPath.Path, "");

            var md = new MethodDescription
            {
                Path        = restPath.Path,
                Description = summary,
                Operations  = verbs.Select(verb =>
                                           new MethodOperation
                {
                    HttpMethod     = verb,
                    Nickname       = verb.ToLowerInvariant() + nickName,
                    Summary        = summary,
                    Notes          = notes,
                    Parameters     = ParseParameters(verb, restPath.RequestType, models),
                    ResponseClass  = GetResponseClass(restPath, models),
                    ErrorResponses = GetMethodResponseCodes(restPath.RequestType)
                }).ToList()
            };

            return(md);
        }
Ejemplo n.º 2
0
        private MethodDescription FormateMethodDescription(RestPath restPath, Dictionary<string, SwaggerModel> models)
        {
            var verbs = new List<string>();
            var summary = restPath.Summary;
            var notes = restPath.Notes;

            if (restPath.AllowsAllVerbs)
            {
                verbs.AddRange(new[] { "GET", "POST", "PUT", "DELETE" });
            }
            else
                verbs.AddRange(restPath.AllowedVerbs.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries));

            var nickName = nicknameCleanerRegex.Replace(restPath.Path, "");

            var md = new MethodDescription
            {
                Path = restPath.Path,
                Description = summary,
                Operations = verbs.Select(verb =>
                    new MethodOperation
                    {
                        HttpMethod = verb,
                        Nickname = verb.ToLowerInvariant() + nickName,
                        Summary = summary,
                        Notes = notes,
                        Parameters = ParseParameters(verb, restPath.RequestType, models),
                        ResponseClass = GetResponseClass(restPath, models),
                        ErrorResponses = GetMethodResponseCodes(restPath.RequestType)
                    }).ToList()
            };
            return md;
        }