/// <summary> /// Creates an operation parameter /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="param">Description of a parameter on an operation via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An operation parameter</returns> public static ResourceApiOperationParameter CreateResourceApiOperationParameter(ApiDescription api, ApiParameterDescription param, XmlCommentDocumentationProvider docProvider) { string paramType = (param.Source.ToString().Equals(FROMURI)) ? QUERY : BODY; ResourceApiOperationParameter parameter = new ResourceApiOperationParameter() { paramType = (paramType == "query" && api.RelativePath.IndexOf("{" + param.Name + "}") > -1) ? PATH : paramType, name = param.Name, description = param.Documentation, dataType = param.ParameterDescriptor.ParameterType.Name, required = docProvider.GetRequired(param.ParameterDescriptor) }; return(parameter); }
/// <summary> /// Creates an operation parameter /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="param">Description of a parameter on an operation via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An operation parameter</returns> public static ResourceApiOperationParameter CreateResourceApiOperationParameter(ResourceListing r, ApiDescription api, ApiParameterDescription param, XmlCommentDocumentationProvider docProvider) { string paramType = (param.Source.ToString().Equals(FROMURI)) ? QUERY : BODY; var dataType = param.ParameterDescriptor.ParameterType.Name; switch (dataType) { case "List`1": var dataObjType = param.ParameterDescriptor.ParameterType.GetGenericArguments()[0]; dataType = string.Format("Array[{0}]", dataObjType.Name); break; case "Nullable`1": var dd = param.ParameterDescriptor.ParameterType.GetGenericArguments()[0]; dataType = dd.Name; break; case "Dictionary`2": dataType = string.Format("Array[{0},{1}]", param.ParameterDescriptor.ParameterType.GetGenericArguments()[0].Name, param.ParameterDescriptor.ParameterType.GetGenericArguments()[1].Name); break; default: if (!IsExceptType(param.ParameterDescriptor.ParameterType)) { AddModelDataObject(r, param.ParameterDescriptor.ParameterType); } break; } ResourceApiOperationParameter parameter = new ResourceApiOperationParameter() { paramType = (paramType == "query" && api.RelativePath.IndexOf("{" + param.Name + "}") > -1) ? PATH : paramType, name = param.Name, description = param.Name.Equals("sessionKey") ? "Login session" : (string.IsNullOrWhiteSpace(param.Documentation) ? NODESCRIPTION : param.Documentation), dataType = dataType, required = docProvider.GetRequired(param.ParameterDescriptor) }; if (string.IsNullOrWhiteSpace(parameter.description) || NODESCRIPTION.Equals(parameter.description, StringComparison.OrdinalIgnoreCase)) { parameter.description = GetParameterDocumentation((param.ParameterDescriptor as ReflectedHttpParameterDescriptor).ParameterInfo, api.ActionDescriptor.ControllerDescriptor.ControllerType); } return(parameter); }
/// <summary> /// Creates an operation parameter /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="param">Description of a parameter on an operation via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An operation parameter</returns> public static ResourceApiOperationParameter CreateResourceApiOperationParameter(ApiDescription api, ApiParameterDescription param, XmlCommentDocumentationProvider docProvider) { string paramType = (param.Source.ToString().Equals(FROMURI)) ? QUERY : BODY; var parameter = new ResourceApiOperationParameter() { paramType = (paramType == "query" && api.RelativePath.IndexOf("{" + param.Name + "}") > -1) ? PATH : paramType, name = param.Name, description = param.Documentation, dataType = TypeParser.Parse(param.ParameterDescriptor.ParameterType), required = docProvider.GetRequired(param.ParameterDescriptor) }; parameter.allowMultiple = parameter.dataType.StartsWith("List["); parameter.allowableValues = CreateAllowableValues(param.ParameterDescriptor.ParameterType); CustomAttributeHelper.PrepareByOptionAttribute(parameter, param.ParameterDescriptor); return(parameter); }
/// <summary> /// Creates an operation parameter /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="param">Description of a parameter on an operation via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An operation parameter</returns> public static ResourceApiOperationParameter CreateResourceApiOperationParameter(ApiDescription api, ApiParameterDescription param, XmlCommentDocumentationProvider docProvider) { string paramType = (param.Source.ToString().Equals(FROMURI)) ? QUERY : BODY; ResourceApiOperationParameter parameter = new ResourceApiOperationParameter() { paramType = (paramType == "query" && api.RelativePath.IndexOf("{" + param.Name + "}") > -1) ? PATH : paramType, name = param.Name, description = param.Documentation, dataType = param.ParameterDescriptor.ParameterType.Name, required = docProvider.GetRequired(param.ParameterDescriptor) }; return parameter; }
/// <summary> /// Creates an operation parameter /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="param">Description of a parameter on an operation via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An operation parameter</returns> public static ResourceApiOperationParameter CreateResourceApiOperationParameter(ApiDescription api, ApiParameterDescription param, XmlCommentDocumentationProvider docProvider) { string paramType = (param.Source.ToString().Equals(FROMURI)) ? QUERY : BODY; var parameter = new ResourceApiOperationParameter() { paramType = (paramType == "query" && api.RelativePath.IndexOf("{" + param.Name + "}") > -1) ? PATH : paramType, name = param.Name, description = param.Documentation, dataType = TypeParser.Parse(param.ParameterDescriptor.ParameterType), required = docProvider.GetRequired(param.ParameterDescriptor) }; parameter.allowMultiple = parameter.dataType.StartsWith("List["); parameter.allowableValues = CreateAllowableValues(param.ParameterDescriptor.ParameterType); CustomAttributeHelper.PrepareByOptionAttribute(parameter, param.ParameterDescriptor); return parameter; }