Esempio n. 1
0
 public HttpActionDocumentation(HttpControllerDocumentation controller, String name, String summary, String alert, String information, HttpActionRequestDocumentation request, HttpActionResponseDocumentation response)
 {
     _Controller = controller;
     _Name = name;
     _Summary = summary;
     _Alert = alert;
     _Information = information;
     _Request = request;
     _Response = response;
 }
        public HttpActionDocumentation GetHttpActionDocumentation(HttpActionDescriptor httpActionDescriptor)
        {
            var reflectedActionDescriptor = (ReflectedHttpActionDescriptor)httpActionDescriptor;
            if (!_WebApiDocumentationMetadata.ApiControllerDocumentation.ContainsKey(httpActionDescriptor.ControllerDescriptor.ControllerType))
            {
                return new HttpActionDocumentation(
                    CreateDefaultControllerDocumentation(reflectedActionDescriptor),
                    reflectedActionDescriptor.ActionName,
                    String.Empty,
                    String.Empty,
                    String.Empty,
                    CreateDefaultRequestDocumentation(reflectedActionDescriptor),
                    CreateDefaultResponseDocumentation(reflectedActionDescriptor));
            }

            var controllerDocumentationMetadata = _WebApiDocumentationMetadata
                .ApiControllerDocumentation
                .SingleOrDefault(controller => controller.Key.Equals(httpActionDescriptor.ControllerDescriptor.ControllerType))
                .Value;
            
            var controllerDocumentation = new HttpControllerDocumentation(
                controllerDocumentationMetadata.ApiControllerType,
                controllerDocumentationMetadata.ResourceName,
                controllerDocumentationMetadata.Summary);

            var actionDocumentationMetadata = controllerDocumentationMetadata
                .HttpActionDocumentationMetadata
                .SingleOrDefault(action => action.Method.Equals(reflectedActionDescriptor.MethodInfo));

            if (actionDocumentationMetadata == null)
            {
                return new HttpActionDocumentation(
                    controllerDocumentation,
                    reflectedActionDescriptor.ActionName,
                    String.Empty,
                    String.Empty,
                    String.Empty,
                    CreateDefaultRequestDocumentation(reflectedActionDescriptor),
                    CreateDefaultResponseDocumentation(reflectedActionDescriptor));
            }

            var actionRequestDocumentation = CreateHttpActionRequestDocumentation(reflectedActionDescriptor, actionDocumentationMetadata);
            var actionResponseDocumentation = CreateHttpActionResponseDocumentation(actionDocumentationMetadata);

            return
                new HttpActionDocumentation(controllerDocumentation,
                                            actionDocumentationMetadata.Name,
                                            actionDocumentationMetadata.Summary,
                                            actionDocumentationMetadata.Alert,
                                            actionDocumentationMetadata.Information,
                                            actionRequestDocumentation,
                                            actionResponseDocumentation);
        }