public void Apply(Schema model, ModelFilterContext context) { var typeNode = _navigator.SelectSingleNode( String.Format(TypeExpression, context.SystemType.XmlLookupName())); if (typeNode != null) { var summaryNode = typeNode.SelectSingleNode(SummaryExpression); if (summaryNode != null) model.description = summaryNode.ExtractContent(); } foreach (var entry in model.properties) { var jsonProperty = context.JsonObjectContract.Properties[entry.Key]; if (jsonProperty == null) continue; ApplyPropertyComments(entry.Value, jsonProperty.PropertyInfo()); } }
private Schema CreateObjectSchema(JsonObjectContract jsonContract) { var properties = jsonContract.Properties .Where(p => !p.Ignored) .Where(p => !(_ignoreObsoleteProperties && p.IsObsolete())) .ToDictionary( prop => prop.PropertyName, prop => CreateInlineSchema(prop.PropertyType).WithValidationProperties(prop) ); var required = jsonContract.Properties.Where(prop => prop.IsRequired()) .Select(propInfo => propInfo.PropertyName) .ToList(); var schema = new Schema { required = required.Any() ? required : null, // required can be null but not empty properties = properties, type = "object" }; foreach (var filter in _schemaFilters) { filter.Apply(schema, this, jsonContract.UnderlyingType); } // NOTE: In next major version, _modelFilters will completely replace _schemaFilters var modelFilterContext = new ModelFilterContext(jsonContract.UnderlyingType, jsonContract, this); foreach (var filter in _modelFilters) { filter.Apply(schema, modelFilterContext); } return schema; }