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 memberInfo = metadata.ContainerType.GetMember(metadata.PropertyName).FirstOrDefault();
                if (memberInfo == null)
                {
                    continue;
                }

                var memberName = XmlCommentsMemberNameHelper.GetMemberNameForMember(memberInfo);
                var memberNode = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, memberName));
                if (memberNode == null)
                {
                    continue;
                }

                var summaryNode = memberNode.SelectSingleNode(SummaryXPath);
                if (summaryNode != null)
                {
                    parameter.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
                }
            }
        }
Beispiel #2
0
        private void ApplyPropertyComments(Schema propertySchema, MemberInfo memberInfo)
        {
            var memberName = XmlCommentsMemberNameHelper.GetMemberNameForMember(memberInfo);
            var memberNode = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, memberName));

            if (memberNode == null)
            {
                return;
            }

            var summaryNode = memberNode.SelectSingleNode(SummaryTag);

            if (summaryNode != null)
            {
                propertySchema.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
            }

            var exampleNode = memberNode.SelectSingleNode(ExampleXPath);

            if (exampleNode != null)
            {
                propertySchema.Example = XmlCommentsTextHelper.Humanize(exampleNode.InnerXml);
            }
        }