GetDocumentation() public method

public GetDocumentation ( HttpActionDescriptor actionDescriptor ) : string
actionDescriptor HttpActionDescriptor
return string
Esempio n. 1
0
        /// <summary>
        /// Creates an api operation
        /// </summary>
        /// <param name="api">Description of the api via the ApiExplorer</param>
        /// <param name="docProvider">Access to the XML docs written in code</param>
        /// <returns>An api operation</returns>
        public static ResourceApiOperation CreateResourceApiOperation(ResourceListing r, ApiDescription api, XmlCommentDocumentationProvider docProvider)
        {
            ResourceApiOperation rApiOperation = new ResourceApiOperation()
            {
                httpMethod    = api.HttpMethod.ToString(),
                nickname      = docProvider.GetNickname(api.ActionDescriptor),
                responseClass = docProvider.GetResponseClass(api.ActionDescriptor),
                summary       = docProvider.GetDocumentation(api.ActionDescriptor),
                notes         = docProvider.GetNotes(api.ActionDescriptor),
                parameters    = new List <ResourceApiOperationParameter>(),
            };

            if (string.IsNullOrEmpty(rApiOperation.notes) || rApiOperation.notes.Equals("No Documentation Found."))
            {
                rApiOperation.notes = rApiOperation.summary;
            }
            return(rApiOperation);
        }
Esempio n. 2
0
        private static IList <ResourceModelNode> CreateResourceModel(ApiParameterDescription param, Type modelType, XmlCommentDocumentationProvider docProvider)
        {
            lock (s_lock)
            {
                var result = new List <ResourceModelNode>();
                ResourceModelNode rModel = null;

                if ((!modelType.IsEnum && !modelType.Equals(typeof(string))))
                {
                    if (modelType.IsGenericType)
                    {
                        modelType = modelType.GetGenericArguments().First();
                        return(CreateResourceModel(param, modelType, docProvider));
                    }

                    if (s_cache.ContainsKey(modelType))
                    {
                        result.AddRange(s_cache[modelType]);
                        return(result);
                    }


                    rModel = new ResourceModelNode()
                    {
                        Id = TypeParser.Parse(modelType.Name)
                    };

                    s_cache.Add(modelType, result);

                    foreach (var typeProperty in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
                    {
                        var property = new ResourceModelPropertyNode();
                        property.Id   = TypeParser.Parse(typeProperty.Name);
                        property.Type = TypeParser.Parse(typeProperty.PropertyType);

                        if (typeProperty.PropertyType.IsValueType || Nullable.GetUnderlyingType(typeProperty.PropertyType) == null)
                        {
                            rModel.Required.Add(property.Id);
                        }

                        if (property.Type.StartsWith("List["))
                        {
                            property.Type = "array";

                            var itemType = typeProperty.PropertyType.GetGenericArguments().FirstOrDefault();

                            if (itemType == null)
                            {
                                itemType = typeProperty.PropertyType;
                            }

                            property.DefineContainerType(itemType);
                        }

                        result.AddRange(CreateResourceModel(typeProperty.PropertyType, docProvider));

                        if (docProvider != null)
                        {
                            property.Description = docProvider.GetDocumentation(typeProperty);

                            if (typeProperty.PropertyType.IsEnum)
                            {
                                property.AllowableValues = CreateAllowableValues(typeProperty.PropertyType);
                            }
                            else if ((typeProperty.PropertyType.IsClass || typeProperty.PropertyType.IsValueType) && typeof(string) != typeProperty.PropertyType)
                            {
                                result.AddRange(CreateResourceModel(typeProperty.PropertyType, docProvider));
                            }
                        }

                        rModel.Properties.Add(property);
                    }

                    if (rModel.Properties.Count > 0)
                    {
                        result.Add(rModel);
                    }
                }

                return(result);
            }
        }
Esempio n. 3
0
        private static IList<ResourceModelNode> CreateResourceModel(ApiParameterDescription param, Type modelType, XmlCommentDocumentationProvider docProvider)
        {
            lock (s_lock)
            {
                var result = new List<ResourceModelNode>();
                ResourceModelNode rModel = null;

                if ((!modelType.IsEnum && !modelType.Equals(typeof(string))))
                {
                    if (modelType.IsGenericType)
                    {
                        modelType = modelType.GetGenericArguments().First();
                        return CreateResourceModel(param, modelType, docProvider);
                    }

                    if (s_cache.ContainsKey(modelType))
                    {
                        result.AddRange(s_cache[modelType]);
                        return result;
                    }


                    rModel = new ResourceModelNode()
                    {
                        Id = TypeParser.Parse(modelType.Name)
                    };

                    s_cache.Add(modelType, result);

                    foreach (var typeProperty in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
                    {
                        var property = new ResourceModelPropertyNode();
                        property.Id = TypeParser.Parse(typeProperty.Name);
                        property.Type = TypeParser.Parse(typeProperty.PropertyType);

                        if (typeProperty.PropertyType.IsValueType || Nullable.GetUnderlyingType(typeProperty.PropertyType) == null)
                        {
                            rModel.Required.Add(property.Id);
                        }

                        if (property.Type.StartsWith("List["))
                        {
                            property.Type = "array";

                            var itemType = typeProperty.PropertyType.GetGenericArguments().FirstOrDefault();

                            if (itemType == null)
                            {
                                itemType = typeProperty.PropertyType;
                            }

                            property.DefineContainerType(itemType);
                        }

                        result.AddRange(CreateResourceModel(typeProperty.PropertyType, docProvider));

                        if (docProvider != null)
                        {
                            property.Description = docProvider.GetDocumentation(typeProperty);

                            if (typeProperty.PropertyType.IsEnum)
                            {
                                property.AllowableValues = CreateAllowableValues(typeProperty.PropertyType);

                            }
                            else if ((typeProperty.PropertyType.IsClass || typeProperty.PropertyType.IsValueType) && typeof(string) != typeProperty.PropertyType)
                            {
                                result.AddRange(CreateResourceModel(typeProperty.PropertyType, docProvider));

                            }
                        }

                        rModel.Properties.Add(property);
                    }

                    if (rModel.Properties.Count > 0)
                    {
                        result.Add(rModel);
                    }
                }

                return result;
            }
        }