Пример #1
0
 IList <ApiResource> getResources(Func <IApiDescription, bool> filter = null, Func <IApiDescription, object> order = null)
 {
     return(apiDescriptionGroupCollectionProvider.ApiDescriptionGroups.Items
            .SelectMany(_ => _.Items
                        .Select(__ => new ApiDescription(__))
                        .Where(filter ?? (__ => true))
                        .OrderBy(__ => (__ as ApiDescription).Description.GroupName)
                        .ThenBy(order ?? (__ => (__ as ApiDescription).Description.RelativePath))
                        .Select(__ => (__ as ApiDescription).Description)
                        .Select(__ =>
     {
         var controllerActionDescriptor = __.ActionDescriptor as ControllerActionDescriptor;
         return new ApiResource
         {
             GroupName = $"{_.GroupName}.{controllerActionDescriptor.ControllerName}",
             Path = __.RelativePath,
             Method = __.HttpMethod,
             Summary = xmlDocmentationReader.GetSummary(controllerActionDescriptor.MethodInfo),
             Produces = __.SupportedRequestFormats.Select(___ => ___.MediaType).ToArray(),
             Parameters = getParameters(__.ParameterDescriptions, controllerActionDescriptor.MethodInfo),
             Responses = getResponses(__.SupportedResponseTypes, controllerActionDescriptor.MethodInfo),
             Changes = getChanges(controllerActionDescriptor.MethodInfo),
             Obsolete = (controllerActionDescriptor.ControllerTypeInfo.GetCustomAttributes <ObsoleteAttribute>().Any() || controllerActionDescriptor.MethodInfo.GetCustomAttributes <ObsoleteAttribute>().Any()) ? true : (bool?)null,
         };
     })
                        )
            .ToList());
 }
        private ApiDefinition getDefinition(Type type, Queue <Type> typeReferences)
        {
            if (type.IsBasic())
            {
                return(null);
            }

            return(new ApiDefinition
            {
                Name = type.GetFriendlyName(true),
                Summary = xmlDocmentationReader.GetSummary(type),
                Properties = getProperties(type, typeReferences),
            });
        }
Пример #3
0
 IList <ApiResource> getResources(Func <IApiDescription, bool> filter = null, Func <IApiDescription, object> order = null)
 {
     return(apiExplorer.ApiDescriptions
            .Select(__ => new ApiDescription(__))
            .Where(filter ?? (__ => true))
            .OrderBy(order ?? (__ => (__ as ApiDescription).Description.RelativePath))
            .Select(__ => (__ as ApiDescription).Description)
            .Select(__ =>
     {
         var reflectedActionDescriptor = __.ActionDescriptor as ReflectedHttpActionDescriptor;
         return new ApiResource
         {
             GroupName = __.ActionDescriptor.ControllerDescriptor.ControllerName,
             Path = __.RelativePath,
             Method = __.HttpMethod.Method,
             Summary = xmlDocmentationReader.GetSummary(reflectedActionDescriptor.MethodInfo),
             //Timestamp = xmlDocmentationReader.GetTimestamp(reflectedActionDescriptor.MethodInfo),
             Produces = __.SupportedRequestBodyFormatters.SelectMany(___ => ___.SupportedMediaTypes.Select(____ => ____.MediaType)).ToArray(),
             Parameters = getParameters(__.ParameterDescriptions, reflectedActionDescriptor.MethodInfo),
             Responses = getResponses(__.ResponseDescription, reflectedActionDescriptor.MethodInfo),
             Changes = getChanges(reflectedActionDescriptor.MethodInfo),
             Obsolete = (__.ActionDescriptor.ControllerDescriptor.GetCustomAttributes <ObsoleteAttribute>().Any() || __.ActionDescriptor.GetCustomAttributes <ObsoleteAttribute>().Any()) ? true : (bool?)null,
         };
     })
            .ToList());
 }