Ejemplo n.º 1
0
        private static string ReplacePathVariables(string url, IList <ParameterApiDescriptionModel> actionParameters)
        {
            var pathParameters = actionParameters
                                 .Where(p => p.BindingSourceId == ParameterBindingSources.Path)
                                 .ToArray();

            if (!pathParameters.Any())
            {
                return(url);
            }

            foreach (var pathParameter in pathParameters)
            {
                url = url.Replace($"{{{pathParameter.Name}}}", $"' + {ProxyScriptingJsFuncHelper.GetParamNameInJsFunc(pathParameter)} + '");
            }

            return(url);
        }
Ejemplo n.º 2
0
        public static string GenerateBody(ActionApiDescriptionModel action)
        {
            var parameters = action
                             .Parameters
                             .Where(p => p.BindingSourceId == ParameterBindingSources.Body)
                             .ToArray();

            if (parameters.Length <= 0)
            {
                return(null);
            }

            if (parameters.Length > 1)
            {
                throw new BaseException(
                          $"Only one complex type allowed as argument to a controller action that's binding source is 'Body'. But {action.Name} ({action.Url}) contains more than one!"
                          );
            }

            return(ProxyScriptingJsFuncHelper.GetParamNameInJsFunc(parameters[0]));
        }
Ejemplo n.º 3
0
        private static string AddQueryStringParameters(string url, IList <ParameterApiDescriptionModel> actionParameters)
        {
            var queryStringParameters = actionParameters
                                        .Where(p => p.BindingSourceId.IsIn(ParameterBindingSources.ModelBinding, ParameterBindingSources.Query))
                                        .ToArray();

            if (!queryStringParameters.Any())
            {
                return(url);
            }

            var qsBuilderParams = queryStringParameters
                                  .Select(p => $"{{ name: '{p.Name.ToCamelCase()}', value: {ProxyScriptingJsFuncHelper.GetParamNameInJsFunc(p)} }}")
                                  .JoinAsString(", ");

            return(url + $"' + abp.utils.buildQueryString([{qsBuilderParams}]) + '");
        }