/// <summary>Updates the <see cref="JsonSchema4.SchemaReferencePath" /> properties /// from the available <see cref="JsonSchema4.SchemaReference" /> properties.</summary> /// <param name="rootObject">The root object.</param> public static void UpdateSchemaReferencePaths(object rootObject) { var schemaReferences = new Dictionary <JsonSchema4, JsonSchema4>(); UpdateSchemaReferencePaths(rootObject, new HashSet <object>(), schemaReferences); var searchedSchemas = schemaReferences.Select(p => p.Value).Distinct(); var result = JsonPathUtilities.GetJsonPaths(rootObject, searchedSchemas); foreach (var p in schemaReferences) { p.Key.SchemaReferencePath = result[p.Value]; } }
/// <summary>Updates the <see cref="IJsonReferenceBase.Reference" /> properties /// from the available <see cref="IJsonReferenceBase.Reference" /> properties.</summary> /// <param name="rootObject">The root object.</param> /// <param name="removeExternalReferences">Specifies whether to remove external references (otherwise they are inlined).</param> /// <param name="contractResolver">The contract resolver.</param> public static void UpdateSchemaReferencePaths(object rootObject, bool removeExternalReferences, IContractResolver contractResolver) { var schemaReferences = new Dictionary <IJsonReference, IJsonReference>(); var updater = new JsonReferencePathUpdater(rootObject, schemaReferences, removeExternalReferences, contractResolver); updater.Visit(rootObject); var searchedSchemas = schemaReferences.Select(p => p.Value).Distinct(); var result = JsonPathUtilities.GetJsonPaths(rootObject, searchedSchemas, contractResolver); foreach (var p in schemaReferences) { p.Key.ReferencePath = result[p.Value]; } }
/// <summary>Updates the <see cref="IJsonReferenceBase.Reference" /> properties /// from the available <see cref="IJsonReferenceBase.Reference" /> properties.</summary> /// <param name="rootObject">The root object.</param> /// <param name="removeExternalReferences">Specifies whether to remove external references (otherwise they are inlined).</param> /// <param name="contractResolver">The contract resolver.</param> public static void UpdateSchemaReferencePaths(object rootObject, bool removeExternalReferences, IContractResolver contractResolver) { var schemaReferences = new Dictionary <IJsonReference, IJsonReference>(); var updater = new JsonReferencePathUpdater(rootObject, schemaReferences, removeExternalReferences, contractResolver); updater.Visit(rootObject); var searchedSchemas = schemaReferences.Select(p => p.Value).Distinct(); var result = JsonPathUtilities.GetJsonPaths(rootObject, searchedSchemas, contractResolver); string referencePath = null; foreach (var p in schemaReferences) { // iiQ Custom result.TryGetValue(p.Value, out referencePath); if (!string.IsNullOrEmpty(referencePath)) { p.Key.ReferencePath = referencePath; } // p.Key.ReferencePath = result[p.Value]; } }