private void ApplyResponsesXmlToResponses(IDictionary <string, Response> responses, XPathNodeIterator responseNodes) { while (responseNodes.MoveNext()) { var code = responseNodes.Current.GetAttribute("code", ""); var response = responses.ContainsKey(code) ? responses[code] : responses[code] = new Response(); response.Description = XmlCommentsTextHelper.Humanize(responseNodes.Current.InnerXml); } }
private void ApplyMethodXmlToOperation(Operation operation, XPathNavigator methodNode) { var summaryNode = methodNode.SelectSingleNode(SummaryXPath); if (summaryNode != null) { operation.Summary = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml); } var remarksNode = methodNode.SelectSingleNode(RemarksXPath); if (remarksNode != null) { operation.Description = XmlCommentsTextHelper.Humanize(remarksNode.InnerXml); } }
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); } } }
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); } } }