public void ShortCircuitOnGraphCycle() { var api = CreateApiDescription(httpConfiguration, actionName: "Cyclical"); TestDelegate call = () => ApiDescriptionExtensions.Flatten(api, api.ParameterDescriptions.Single(), documentationProvider); Assert.That(call, Throws.Nothing); }
public void ConvertComplexWithArray() { var api = CreateApiDescription(httpConfiguration, actionName: "ComplexWithArray"); var results = ApiDescriptionExtensions.Flatten(api, api.ParameterDescriptions.Single(), documentationProvider); var result = results.Single(); Assert.That(result.IsMany, Is.True, "SimpleApiDescription.IsMany"); }
public void ConvertArray() { var api = CreateApiDescription(httpConfiguration, actionName: "Array"); var results = ApiDescriptionExtensions.Flatten(api, api.ParameterDescriptions.Single(), documentationProvider); var result = results.Single(); Assert.That(result.Name, Is.EqualTo("array")); Assert.That(result.IsOptional, Is.False, "IsOptional"); Assert.That(result.CallingConvention, Is.EqualTo("body")); Assert.That(result.IsMany, Is.True, "SimpleApiDescription.IsMany"); }
public void NonSimpleType() { Assert.That(ApiDescriptionExtensions.IsSimpleType(typeof(Model)), Is.False, "For type " + typeof(Model)); }
public void SimpleTypes(Type type) { Assert.That(ApiDescriptionExtensions.IsSimpleType(type), Is.True, "For type " + type); }
/// <summary> /// Process <c>See</c> tag. /// </summary> /// <param name="helpBlock">Hte original help block string.</param> /// <param name="urlHelper">The url helper for link building.</param> /// <returns>The html content.</returns> private string RenderSeeTag(string helpBlock, UrlHelper urlHelper) { string result = helpBlock; Match match = null; while ((match = HelpBlockRenderer.regexSeeTag.Match(result)).Success) { var originalValues = match.Value; var prefix = match.Groups["prefix"].Value; var anchorText = string.Empty; var link = string.Empty; switch (prefix) { case "T": { // if See tag has reference to type, then get value from member regex group. var modelType = match.Groups["member"].Value; anchorText = modelType.Substring(modelType.LastIndexOf(".") + 1); link = urlHelper.Action("ResourceModel", "Help", new { modelName = anchorText, area = "ApiHelpPage" }); break; } case "M": { // Check that specified type member is API member. var apiDescriptor = this.GetApiDescriptor(match.Groups["member"].Value); if (apiDescriptor != null) { anchorText = apiDescriptor.ActionDescriptor.ActionName; link = urlHelper.Action("Api", "Help", new { apiId = ApiDescriptionExtensions.GetFriendlyId(apiDescriptor), area = "ApiHelpPage" }); } else { // Web API Help can generate help only for whole API model, // So, in case if See tag contains link to model member, replace link with link to model class. var modelType = match.Groups["member"].Value.Substring(0, match.Groups["member"].Value.LastIndexOf(".")); anchorText = modelType.Substring(modelType.LastIndexOf(".") + 1); link = urlHelper.Action("ResourceModel", "Help", new { modelName = anchorText, area = "ApiHelpPage" }); } break; } default: { anchorText = match.Groups["member"].Value; // By default link will be rendered with empty anrchor. link = "#"; break; } } // Build the anchor. var anchor = string.Format("<a href=\"{0}\">{1}</a>", link, anchorText); result = result.Replace(originalValues, anchor); } return(result); }