コード例 #1
0
ファイル: SwaggerModels.cs プロジェクト: DveMac/Swagger.Net
        /// <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;
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
 /// <summary>
 /// Adds an API to the liting.
 /// </summary>
 /// <param name="api">An API.</param>
 public void AddApi(ResourceApi api)
 {
     m_apis.Add(api);
 }
コード例 #5
0
 /// <summary>
 /// Adds an API to the liting.
 /// </summary>
 /// <param name="api">An API.</param>
 public void AddApi(ResourceApi api)
 {
     m_apis.Add(api);
 }