private Schema CreateObjectSchema(JsonObjectContract jsonContract) { Dictionary <string, Schema> properties = (from p in jsonContract.Properties where !p.Ignored where !this._ignoreObsoleteProperties || !p.IsObsolete() select p).ToDictionary((JsonProperty prop) => prop.PropertyName, (JsonProperty prop) => this.CreateInlineSchema(prop.PropertyType).WithValidationProperties(prop)); List <string> list = (from prop in jsonContract.Properties where prop.IsRequired() select prop into propInfo select propInfo.PropertyName).ToList <string>(); Schema schema = new Schema { required = list.Any <string>() ? list : null, properties = properties, type = "object" }; foreach (ISchemaFilter current in this._schemaFilters) { current.Apply(schema, this, jsonContract.UnderlyingType); } ModelFilterContext context = new ModelFilterContext(jsonContract.UnderlyingType, jsonContract, this); foreach (IModelFilter current2 in this._modelFilters) { current2.Apply(schema, context); } return(schema); }
public void Apply(Schema model, ModelFilterContext context) { string commentIdForType = XmlCommentsIdHelper.GetCommentIdForType(context.SystemType); XPathNavigator xPathNavigator = this._navigator.SelectSingleNode(string.Format("/doc/members/member[@name='{0}']", commentIdForType)); if (xPathNavigator != null) { XPathNavigator xPathNavigator2 = xPathNavigator.SelectSingleNode("summary"); if (xPathNavigator2 != null) { model.description = xPathNavigator2.ExtractContent(); } } foreach (KeyValuePair <string, Schema> current in model.properties) { JsonProperty jsonProperty = context.JsonObjectContract.Properties[current.Key]; if (jsonProperty != null) { this.ApplyPropertyComments(current.Value, jsonProperty.PropertyInfo()); } } }