private static void FixSchemaReference(SchemaRegistry registry, Schema schema, Type referencedType) { Contract.Requires(schema.@ref != null); var schemaIdSelector = registry.GetInstanceField <Func <Type, string> >("_schemaIdSelector", true); schema.@ref = "#/definitions/" + schemaIdSelector(referencedType); }