Skip to content

Commit

Permalink
add mechanism to fetch local schema
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsdennis committed Aug 5, 2023
1 parent b2b9970 commit db49b4c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions JsonSchema/JsonSchema.csproj
Expand Up @@ -16,8 +16,8 @@
<PackageProjectUrl>https://github.com/gregsdennis/json-everything</PackageProjectUrl>
<RepositoryUrl>https://github.com/gregsdennis/json-everything</RepositoryUrl>
<PackageTags>json-schema validation schema json</PackageTags>
<Version>5.1.0</Version>
<FileVersion>5.1.0.0</FileVersion>
<Version>5.1.1</Version>
<FileVersion>5.1.1.0</FileVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<AssemblyName>JsonSchema.Net</AssemblyName>
Expand Down
15 changes: 15 additions & 0 deletions JsonSchema/SchemaConstraint.cs
Expand Up @@ -103,4 +103,19 @@ public SchemaEvaluation BuildEvaluation(JsonNode? localInstance, JsonPointer ins

return evaluation;
}

/// <summary>
/// Gets the local schema object.
/// </summary>
/// <param name="options">Evaluation options.</param>
/// <returns>The local <see cref="JsonSchema"/> object represented by this constraint.</returns>
/// <remarks>
/// This method can lead to inefficiencies. It is provided as a last resort to access the schema directly.
/// </remarks>
public JsonSchema GetLocalSchema(EvaluationOptions options)
{
var baseSchema = options.SchemaRegistry.Get(SchemaBaseUri);

return baseSchema!.FindSubschema(BaseInstanceLocation, options)!;
}
}
4 changes: 4 additions & 0 deletions tools/ApiDocsGenerator/release-notes/rn-json-schema.md
Expand Up @@ -4,6 +4,10 @@ title: JsonSchema.Net
icon: fas fa-tag
order: "8.01"
---
# [5.1.1](commit) {#release-schema-5.1.1}

Added `SchemaConstraint.GetLocalSchema()` for accessing the local schema. (To be used as a last resort, but may be necessary.)

# [5.1.0](https://github.com/gregsdennis/json-everything/pull/499) {#release-schema-5.1.0}

[#493](https://github.com/gregsdennis/json-everything/issues/493) - Add support for reporting error messages in multiple cultures in parallel. Thanks to [@m-adamkiewicz](https://github.com/m-adamkiewicz) for the suggestion.
Expand Down

0 comments on commit db49b4c

Please sign in to comment.