Ejemplo n.º 1
0
        public void Apply(Schema schema, SchemaFilterContext context)
        {
            var jsonObjectContract = context.JsonContract as JsonObjectContract;

            if (jsonObjectContract == null)
            {
                return;
            }

            var commentId = XmlCommentsIdHelper.GetCommentIdForType(context.SystemType);
            var typeNode  = _xmlNavigator.SelectSingleNode(string.Format(MemberXPath, commentId));

            if (typeNode != null)
            {
                var summaryNode = typeNode.SelectSingleNode(SummaryTag);
                if (summaryNode != null)
                {
                    schema.Description = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
                }
            }

            if (schema.Properties == null)
            {
                return;
            }
            foreach (var entry in schema.Properties)
            {
                var jsonProperty = jsonObjectContract.Properties[entry.Key];
                if (jsonProperty == null)
                {
                    continue;
                }

                var propertyInfo = jsonProperty.PropertyInfo();
                if (propertyInfo != null)
                {
                    ApplyPropertyComments(entry.Value, propertyInfo);
                }
            }
        }