Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link the keywords to their respective pages #244

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
05acf4e
add description and examples for contentEncoding keyword
AgniveshChaubey Mar 31, 2024
a8b51b6
add the proposed encoding formats
AgniveshChaubey Mar 31, 2024
c9e976a
add title to schema
AgniveshChaubey Mar 31, 2024
78b3685
format the annotation output
AgniveshChaubey Apr 18, 2024
b410b08
temp commit
AgniveshChaubey Apr 18, 2024
246aac0
Merge branch 'main' into contentEncoding
AgniveshChaubey Apr 18, 2024
4ad4034
address the suggested changes
AgniveshChaubey Apr 22, 2024
066ab9e
Merge branch 'contentEncoding' of https://github.com/Intelligence-AI/…
AgniveshChaubey Apr 24, 2024
36571d2
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey Apr 24, 2024
09eb129
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 2, 2024
f1d37c5
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 3, 2024
6cf6c04
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 3, 2024
7366bf7
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 6, 2024
b7bc6bd
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 9, 2024
8982f61
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 12, 2024
1ce8e9f
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 17, 2024
b4a4171
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 18, 2024
29308fc
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 20, 2024
b7d1b1b
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 24, 2024
ade920b
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 27, 2024
8d8d44c
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 29, 2024
542776f
Merge branch 'main' of https://github.com/Intelligence-AI/learnjsonsc…
AgniveshChaubey May 29, 2024
105ab47
shortcode for creating keyword link
AgniveshChaubey May 30, 2024
fcb12f9
Merge branch 'main' into keyword-link
AgniveshChaubey May 30, 2024
446d7fb
add link to the keywords using shortcode
AgniveshChaubey May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions content/2020-12/applicator/additionalProperties.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ related:
keyword: unevaluatedProperties
---

The `additionalProperties` keyword is used to control the handling of properties whose names are not listed in the `properties` keyword or match any of the regular expressions in the `patternProperties` keyword. By default any additional properties are allowed.
The {{<keyword-link name="additionalProperties" >}} keyword is used to control the handling of properties whose names are not listed in the {{<keyword-link name="properties" >}} keyword or match any of the regular expressions in the {{<keyword-link name="patternProperties" >}} keyword. By default any additional properties are allowed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we always require a vocabulary name when using the shortcode? As we might be linking to keywords in other vocabularies?


The behavior of this keyword depends on the presence and annotation results of `properties` and `patternProperties` within the same schema object. Validation with `additionalProperties` applies only to the child values of instance names that do not appear in the annotation results of either `properties` or `patternProperties`.
The behavior of this keyword depends on the presence and annotation results of {{<keyword-link name="properties" >}} and {{<keyword-link name="patternProperties" >}} within the same schema object. Validation with {{<keyword-link name="additionalProperties" >}} applies only to the child values of instance names that do not appear in the annotation results of either {{<keyword-link name="properties" >}} or {{<keyword-link name="patternProperties" >}}.

## Examples

Expand All @@ -68,7 +68,7 @@ The behavior of this keyword depends on the presence and annotation results of `
{{<instance-fail `An instance with additional properties is invalid`>}}
{ "foo": "foo", "bar": "bar" }
{{</instance-fail>}}
* _When `additionalProperties` is set to false, all the instance properties must either be present in the `properties` or match any regex within `patternProperties`; otherwise, the validaion will fail._
* _When {{<keyword-link name="additionalProperties" >}} is set to false, all the instance properties must either be present in the {{<keyword-link name="properties" >}} or match any regex within {{<keyword-link name="patternProperties" >}}; otherwise, the validaion will fail._

{{<schema `Schema with 'additionalProperties' set to an object schema`>}}
{
Expand All @@ -94,7 +94,7 @@ The behavior of this keyword depends on the presence and annotation results of `
{{<instance-fail `The value of 'age' must be a number`>}}
{ "name": "John Doe", "age": "21" }
{{</instance-fail>}}
* _The value of `additionalProperties` can either be a boolean schema or an object schema._
* _The value of {{<keyword-link name="additionalProperties" >}} can either be a boolean schema or an object schema._

{{<schema `Schema with 'patternProperties', 'properties' and 'additionalProperties' keyword`>}}
{
Expand Down Expand Up @@ -131,7 +131,7 @@ The behavior of this keyword depends on the presence and annotation results of `
{ "keyword": "/patternProperties", "instance": "", "value": [ "Age" ] }
{ "keyword": "/additionalProperties", "instance": "", "value": [ "email" ] }
{{</instance-annotation>}}
* _Instance properties (keys) not present in `properties` or not matching any regex within `patternProperties` are evaluated against `additionalProperties`._
* _Instance properties (keys) not present in {{<keyword-link name="properties" >}} or not matching any regex within {{<keyword-link name="patternProperties" >}} are evaluated against {{<keyword-link name="additionalProperties" >}}._

{{<schema `Schema with no 'additionalProperties' defined`>}}
{
Expand Down Expand Up @@ -175,4 +175,4 @@ The behavior of this keyword depends on the presence and annotation results of `
{ "keyword": "/patternProperties", "instance": "", "value": [ "Age" ] }
{{</instance-annotation>}}

_**Note:** JSON Schema is a constraint language and if you don't limit keywords like this, then more keywords than what you defined in `properties`, etc would be allowed. If you don't define a property using `properties` or `patternProperties`, but don't disallow it with `additionalProperties`, it would still be valid with any value._
_**Note:** JSON Schema is a constraint language and if you don't limit keywords like this, then more keywords than what you defined in {{<keyword-link name="properties" >}}, etc would be allowed. If you don't define a property using {{<keyword-link name="properties" >}} or {{<keyword-link name="patternProperties" >}}, but don't disallow it with {{<keyword-link name="additionalProperties" >}}, it would still be valid with any value._
4 changes: 2 additions & 2 deletions content/2020-12/applicator/allOf.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ related:
keyword: not
---

The `allOf` keyword is used to specify that a given instance must validate against all of the subschemas provided within an array. It's essentially a logical "AND" operation where all conditions must be met for validation to pass.
The {{<keyword-link name="allOf" >}} keyword is used to specify that a given instance must validate against all of the subschemas provided within an array. It's essentially a logical "AND" operation where all conditions must be met for validation to pass.

## Examples

Expand Down Expand Up @@ -129,7 +129,7 @@ The `allOf` keyword is used to specify that a given instance must validate again
{{<instance-fail `An instance conforming to the second subschema of 'allOf' is also invalid`>}}
{ "foo": "foo" }
{{</instance-fail>}}
* _Remember, if any subschema within the `allOf` keyword fails validation or has a boolean `false` value, the entire validation will always fail._
* _Remember, if any subschema within the {{<keyword-link name="allOf" >}} keyword fails validation or has a boolean `false` value, the entire validation will always fail._

{{<schema `Schema with nested 'allOf'`>}}
{
Expand Down
12 changes: 6 additions & 6 deletions content/2020-12/applicator/anyOf.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ related:
keyword: not
---

The `anyOf` keyword in JSON Schema is used to specify that an instance must validate against at least one of the schemas provided in an array. It allows you to define multiple schemas, and if the data validates against any one of them, the validation passes.
The {{<keyword-link name="anyOf" >}} keyword in JSON Schema is used to specify that an instance must validate against at least one of the schemas provided in an array. It allows you to define multiple schemas, and if the data validates against any one of them, the validation passes.

## Examples

Expand Down Expand Up @@ -133,7 +133,7 @@ The `anyOf` keyword in JSON Schema is used to specify that an instance must vali
{{<instance-pass `An instance not conforming to the second subschema of 'anyOf' is also valid`>}}
{ "foo": true }
{{</instance-pass>}}
* _Remember, if any subschema within the `anyOf` keyword passes validation or has a boolean `true` value, the overall result of `anyOf` is considered valid._
* _Remember, if any subschema within the {{<keyword-link name="anyOf" >}} keyword passes validation or has a boolean `true` value, the overall result of {{<keyword-link name="anyOf" >}} is considered valid._

{{<schema `Schema with nested 'anyOf'`>}}
{
Expand All @@ -160,15 +160,15 @@ The `anyOf` keyword in JSON Schema is used to specify that an instance must vali
{{<instance-pass `An instance not conforming to the second subschema of top-level 'anyOf' is also valid`>}}
10
{{</instance-pass>}}
* _For the first instance above, validation passes against the first subschema within `anyOf`, thereby making the `anyOf` keyword valid, regardless of the validation result against the second subschema._
* _For the first instance above, validation passes against the first subschema within {{<keyword-link name="anyOf" >}}, thereby making the {{<keyword-link name="anyOf" >}} keyword valid, regardless of the validation result against the second subschema._

* _Similarly, for the second instance above, validation passes against the first subschema within `anyOf`. Even though the instance does not conform to the second subschema, validation does not proceed to validate against it, as it has already been successfully validated against the first subschema. Thus, the validation stops at that point, rendering the `anyOf` valid, despite the instance not conforming to the second subschema within the `anyOf`._
* _Similarly, for the second instance above, validation passes against the first subschema within {{<keyword-link name="anyOf" >}}. Even though the instance does not conform to the second subschema, validation does not proceed to validate against it, as it has already been successfully validated against the first subschema. Thus, the validation stops at that point, rendering the {{<keyword-link name="anyOf" >}} valid, despite the instance not conforming to the second subschema within the {{<keyword-link name="anyOf" >}}._

{{<common-pitfall>}}
Important note on performance and annotations:

* When running validation only, a JSON Schema implementation may stop validating `anyOf` when it encounters a successful one. However, when collecting annotations, it must evaluate all of them.
* The process of collecting annotations can impact runtime performance. For instance, if you collect annotations on a JSON Schema utilizing the `anyOf` applicator, the implementation is forced to evaluate the instance against every disjunction in the `anyOf` applicator. Conversely, if annotations are not collected, implementations may stop evaluation as soon as one `anyOf` subschema successfully validates against the instance.
* When running validation only, a JSON Schema implementation may stop validating {{<keyword-link name="anyOf" >}} when it encounters a successful one. However, when collecting annotations, it must evaluate all of them.
* The process of collecting annotations can impact runtime performance. For instance, if you collect annotations on a JSON Schema utilizing the {{<keyword-link name="anyOf" >}} applicator, the implementation is forced to evaluate the instance against every disjunction in the {{<keyword-link name="anyOf" >}} applicator. Conversely, if annotations are not collected, implementations may stop evaluation as soon as one {{<keyword-link name="anyOf" >}} subschema successfully validates against the instance.
* In the interest of runtime efficiency, we recommend collecting annotations only if your specific use case demands it.

{{</common-pitfall>}}
8 changes: 4 additions & 4 deletions content/2020-12/applicator/contains.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ related:
keyword: unevaluatedItems
---

The `contains` keyword is used to check if at least one element in an array instance validates against a specified sub-schema. It offers flexibility compared to `items`, which requires all elements to adhere to a single schema.
The {{<keyword-link name="contains" >}} keyword is used to check if at least one element in an array instance validates against a specified sub-schema. It offers flexibility compared to {{<keyword-link name="items" >}}, which requires all elements to adhere to a single schema.

An array instance is valid against `contains` if at least one of its elements is valid against the given schema, except when `minContains` is present and has a value of 0, in which case an array instance must be considered valid against the `contains` keyword, even if none of its elements is valid against the given schema.
An array instance is valid against {{<keyword-link name="contains" >}} if at least one of its elements is valid against the given schema, except when {{<keyword-link name="minContains" >}} is present and has a value of 0, in which case an array instance must be considered valid against the {{<keyword-link name="contains" >}} keyword, even if none of its elements is valid against the given schema.

Similarly, if `maxContains` is present alongside `contains`, the instance will be considered valid as long as the number of elements successfully validating against the `contains` subschema does not exceed the specified limit defined by `maxContains`.
Similarly, if {{<keyword-link name="maxContains" >}} is present alongside {{<keyword-link name="contains" >}}, the instance will be considered valid as long as the number of elements successfully validating against the {{<keyword-link name="contains" >}} subschema does not exceed the specified limit defined by {{<keyword-link name="maxContains" >}}.

* For data validation, `items` validates all array elements against a single schema, `prefixItems` validates a fixed-length sequence at the array's beginning, and `contains` checks for at least one element matching a schema anywhere in the array.
* For data validation, {{<keyword-link name="items" >}} validates all array elements against a single schema, {{<keyword-link name="prefixItems" >}} validates a fixed-length sequence at the array's beginning, and {{<keyword-link name="contains" >}} checks for at least one element matching a schema anywhere in the array.
* The subschema must be applied to every array element, even after the first match has been found, to collect annotations for use by other keywords.

## Examples
Expand Down
2 changes: 1 addition & 1 deletion content/2020-12/applicator/dependentSchemas.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ related:
keyword: dependentRequired
---

The `dependentSchemas` keyword allows you to define dependencies between properties based on the presence of other properties within an instance. It extends the functionality of the `dependentRequired` keyword by allowing you to pass in a full schema. The instance will be considered valid only if the dependent properties adhere to the `dependentSchemas` schema.
The {{<keyword-link name="dependentSchemas" >}} keyword allows you to define dependencies between properties based on the presence of other properties within an instance. It extends the functionality of the {{<keyword-link name="dependentRequired" >}} keyword by allowing you to pass in a full schema. The instance will be considered valid only if the dependent properties adhere to the {{<keyword-link name="dependentSchemas" >}} schema.

* Each key in the object represents a property name.
* Instance is valid if the associated property is present and conforms to the subschema.
Expand Down
15 changes: 15 additions & 0 deletions layouts/shortcodes/keyword-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- $keyword := .Get "name" -}}
{{- $keywordMap := dict -}}
{{- range $.Site.RegularPages -}}
{{- $dialect := .Section -}}
{{- $vocabulary := .Parent.Title -}}
{{- $keywordParam := .Params.keyword -}}
{{- $url := .Permalink -}}
{{- $keywordMap = $keywordMap | merge (dict $keywordParam $url) -}}
{{- end -}}
{{- $url := index $keywordMap $keyword -}}
{{- if $url -}}
<a href="{{ $url }}">{{ $keyword }}</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hugo has a ref shortcode that ensures the destination is a valid page (thus protecting against broken links): https://gohugo.io/content-management/cross-references/. Can you make use of those here?

{{- else -}}
{{ $keyword }}
{{- end -}}
Loading