/// <summary> /// Create an api element /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <returns>A resource api</returns> public static ResourceApi CreateResourceApi(ApiDescription api) { ResourceApi rApi = new ResourceApi() { path = "/" + api.RelativePath, description = api.Documentation, operations = new List<ResourceApiOperation>() }; return rApi; }
private bool IsDuplicate(ApiDescription api, ResourceApi rapi, List<ResourceApi> existing) { if (!api.HttpMethod.Method.Equals(api.ActionDescriptor.ActionName, StringComparison.CurrentCultureIgnoreCase)) return false; var controllerName = api.ActionDescriptor.ControllerDescriptor.ControllerName; var actionName = api.ActionDescriptor.ActionName; var uglySyntax = string.Format("/api/{0}/{1}", controllerName, actionName); var prettySyntax = string.Format("/api/{0}", controllerName); if (!rapi.path.StartsWith(uglySyntax, StringComparison.CurrentCultureIgnoreCase)) return false; return existing.Any(e => e.path.StartsWith(prettySyntax, StringComparison.CurrentCultureIgnoreCase)); }
/// <summary> /// Create an api element /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <returns>A resource api</returns> public static ResourceApi CreateResourceApi(ApiDescription api) { ResourceApi rApi = new ResourceApi() { path = "/" + api.RelativePath, description = DocsService.GetXmlFromType(api.ActionDescriptor.ControllerDescriptor.ControllerType, false).InnerText, operations = new List<ResourceApiOperation>() }; CustomAttributeHelper.PrepareByOptionAttribute(rApi, api.ActionDescriptor); return rApi; }
/// <summary> /// Adds an API to the liting. /// </summary> /// <param name="api">An API.</param> public void AddApi(ResourceApi api) { m_apis.Add(api); }