Ejemplo n.º 1
0
        private void ApplyPropertyComments(Schema propertySchema, PropertyInfo propertyInfo)
        {
            var commentId    = XmlCommentsIdHelper.GetCommentIdForProperty(propertyInfo);
            var propertyNode = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, commentId));

            if (propertyNode == null)
            {
                return;
            }

            var summaryNode = propertyNode.SelectSingleNode(SummaryTag);

            if (summaryNode != null)
            {
                propertySchema.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
            }
        }
        private void ApplyPropertiesXmlToPropertyParameters(
            IList <IParameter> parameters,
            ApiDescription apiDescription)
        {
            if (parameters == null)
            {
                return;
            }

            foreach (var parameter in parameters)
            {
                // Check for a corresponding  API parameter (from ApiExplorer) that's property-bound?
                var propertyParam = apiDescription.ParameterDescriptions
                                    .Where(p => p.ModelMetadata.ContainerType != null && p.ModelMetadata.PropertyName != null)
                                    .FirstOrDefault(p => parameter.Name.Equals(p.Name, StringComparison.OrdinalIgnoreCase));
                if (propertyParam == null)
                {
                    continue;
                }

                var metadata     = propertyParam.ModelMetadata;
                var propertyInfo = metadata.ContainerType.GetTypeInfo().GetProperty(metadata.PropertyName);
                if (propertyInfo == null)
                {
                    continue;
                }

                var commentId    = XmlCommentsIdHelper.GetCommentIdForProperty(propertyInfo);
                var propertyNode = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, commentId));
                if (propertyNode == null)
                {
                    continue;
                }

                var summaryNode = propertyNode.SelectSingleNode(SummaryXPath);
                if (summaryNode != null)
                {
                    parameter.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
                }
            }
        }