-
-
Notifications
You must be signed in to change notification settings - Fork 358
docs: correct type list and fix typos in type-specific keywords page #1952 #1954
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
base: main
Are you sure you want to change the base?
Conversation
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1954 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 30 30
Lines 633 633
Branches 196 196
=========================================
Hits 633 633 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jdesrosiers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fix this. There's one more thing we can fix while we're here. See the inline comment.
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, `regular expressions`, or `string`). This specifies that the instance data is only valid when it matches that specific type. | ||
|
|
||
| Here is an example of using the `string` keyword as a single string: | ||
| Here is an example of using the `number` keyword as a single string: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually only refer to the property names as "keywords", not their values. So, type is a keyword and "number" is the value of that keyword.
| Here is an example of using the `number` keyword as a single string: | |
| Here is an example of using `"number"` as a single string value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jdesrosiers , pushed the requested changes. Lmk if you need tweaks .
jdesrosiers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I noticed a couple more things that are wrong. Not sure when this got so broken, but I appreciate you fixing these issues as well. Thanks.
| - [array](../../understanding-json-schema/reference/array) | ||
| - [boolean](../../understanding-json-schema/reference/boolean) | ||
| - [null](../../understanding-json-schema/reference/null) | ||
| - [numeric types](../../understanding-json-schema/reference/numeric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"numeric types" is not a type.
| - [integer](../../understanding-json-schema/reference/numeric) | |
| - [number](../../understanding-json-schema/reference/numeric) |
| - [null](../../understanding-json-schema/reference/null) | ||
| - [numeric types](../../understanding-json-schema/reference/numeric) | ||
| - [object](../../understanding-json-schema/reference/object) | ||
| - [regular expressions](../../understanding-json-schema/reference/regular_expressions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"regular expressions" is not a type.
|
|
||
| The `type` keyword can take two forms: | ||
|
|
||
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, `regular expressions`, or `string`). This specifies that the instance data is only valid when it matches that specific type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"regular expressions" is not a type.
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, `regular expressions`, or `string`). This specifies that the instance data is only valid when it matches that specific type. | |
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, or `string`). This specifies that the instance data is only valid when it matches that specific type. |
jdesrosiers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for continuing to iterate on this.
There's a nuance about types that isn't communicated here properly. (Again, I don't know how this got so bad. It didn't used to be like this.) JSON has six types: null, boolean, number, string, array, and object. "Integer" is not a JSON type.
JSON Schema does something confusing where it allows for a seventh value for type called "integer". This does not mean that JSON or JSON Schema supports integers. It's effectively a shorthand for { "type": "number", "multipleOf": 1 } for describing numbers that are restricted to the set of integers.
So, adding "integer" to all the tables is not the right thing to do.
|
|
||
| [2] JSON does not have separate types for integer and | ||
| floating-point. | ||
| [2] JSON defines a single numeric literal, but JSON Schema distinguishes between `number` (any numeric value) and `integer` (no fractional part). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct. JSON Schema is uses the mathematical value, not the way number is represented. So, 1.0 is considered an integer even though it contains a fractional part.
I think you can revert this and the other footnote changes. The original was fine.
| | [array](../../understanding-json-schema/reference/array) | `items`, `additionalItems`, `minItems`, `maxItems`, `uniqueItems` | Define item schemas, additional item handling, item count constraints, and uniqueness. | | ||
| | [number](../../understanding-json-schema/reference/numeric) | `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf` | Define numeric ranges, including exclusive bounds and divisibility. | | ||
| | [object](../../understanding-json-schema/reference/object) | `required`, `properties`, `additionalProperties`, `patternProperties`, `minProperties`, `maxProperties`, `dependencies` | Define required properties, property schemas, additional property handling, pattern-based property matching, and property count constraints. | | ||
| | [integer](../../understanding-json-schema/reference/numeric) | Same as `number` | Integers use numeric constraints but must not contain a fractional part. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, the fractional part is not relevant. I don't think we need this row, but maybe we can update the number row to number/integer or something like that.
| It should be noted that `format` is not limited to a specific set of valid values or types. Users may define their own custom keywords including ones that work with JSON data types other than `string`, such as `number`. Below, we cover the formats specified in the JSON Schema specification. | ||
| It should be noted that `format` is not limited to a specific set of valid values or types. Users may define custom formats through vocabularies, but the built-in formats apply only to strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was more clear before except for the error of calling it "custom keywords" instead of "custom formats". Also, formats can't be added through vocabularies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. I misunderstood the role of "integer" in JSON Schema and treated it as a base JSON type instead of a specialized constraint on "number".
275d269 to
7db6856
Compare
| The `type` keyword can take two forms: | ||
|
|
||
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, `regular expressions`, or `string`). This specifies that the instance data is only valid when it matches that specific type. | ||
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean` , `number`, `null`, `object` or `string`). This specifies that the instance data is only valid when it matches that specific type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean` , `number`, `null`, `object` or `string`). This specifies that the instance data is only valid when it matches that specific type. | |
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `number`, `null`, `object` or `string`). This specifies that the instance data is only valid when it matches that specific type. |
| ### Built-in Formats | ||
|
|
||
| It should be noted that `format` is not limited to a specific set of valid values or types. Users may define their own custom keywords including ones that work with JSON data types other than `string`, such as `number`. Below, we cover the formats specified in the JSON Schema specification. | ||
| It should be noted that `format` is not limited to a specific set of valid values or types. Users may define additional custom formats, but the built-in formats apply only to the `string` type. Below, we cover the formats defined in the JSON Schema specification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still doesn't quite communicate what it needs to say. It's supposed to clarify that just because all of the formats in the spec apply to strings, doesn't mean custom formats can't apply to types other than strings. I'm not understanding that from the current wording. The original wording was fine other than calling them "custom keywords" instead of "custom formats".
| At its core, JSON Schema defines the following basic types: | ||
|
|
||
| - [array](../../understanding-json-schema/reference/array) | ||
| - [boolean](../../understanding-json-schema/reference/boolean) | ||
| - [null](../../understanding-json-schema/reference/null) | ||
| - [numeric types](../../understanding-json-schema/reference/numeric) | ||
| - [number](../../understanding-json-schema/reference/numeric) | ||
| - [object](../../understanding-json-schema/reference/object) | ||
| - [regular expressions](../../understanding-json-schema/reference/regular_expressions) | ||
| - [string](../../understanding-json-schema/reference/string) | ||
|
|
||
|
|
||
| These types have analogs in most programming languages, though they may | ||
| go by different names. | ||
|
|
||
| > Note: JSON does not define an `integer` type. In JSON Schema, `"integer"` is shorthand for `"number"` with `"multipleOf": 1`, used to represent whole-number numeric values. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At no point do we document that the type keyword takes "integer". I think something like this works better.
| The `type` keyword defines the following types: | |
| - [array](../../understanding-json-schema/reference/array) | |
| - [boolean](../../understanding-json-schema/reference/boolean) | |
| - [null](../../understanding-json-schema/reference/null) | |
| - [integer](../../understanding-json-schema/reference/numeric) | |
| - [number](../../understanding-json-schema/reference/numeric) | |
| - [object](../../understanding-json-schema/reference/object) | |
| - [string](../../understanding-json-schema/reference/string) | |
| > Note: JSON does not define an `integer` type. In JSON Schema, `"type": "integer"` is shorthand for `"type": "number", "multipleOf": 1`, and is used to represent whole-number numeric values. | |
| These types have analogs in most programming languages, though they may | |
| go by different names. | |
jdesrosiers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed one in the last review.
| The `type` keyword can take two forms: | ||
|
|
||
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `integer`, `number`, `null`, `object`, `regular expressions`, or `string`). This specifies that the instance data is only valid when it matches that specific type. | ||
| 1. **A single string**. When it is a single string, it must be one of the types mentioned above (`array`, `boolean`, `number`, `null`, `object` or `string`). This specifies that the instance data is only valid when it matches that specific type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should include "integer" because it's talking about the values the type keyword accepts.
What kind of change does this PR introduce?
Documentation fix (typo corrections and type-list accuracy improvements)
Issue Number:
Screenshots/videos:
N/A (text-only documentation changes)
If relevant, did you update the documentation?
Yes — this PR directly updates the documentation page.
Summary
This PR corrects multiple inaccuracies in the Type-specific Keywords documentation:
These improvements increase correctness, clarity, and consistency across the documentation.
Does this PR introduce a breaking change?
No. Documentation-only changes.
Checklist