remove non ascii whitespaces
This commit is contained in:
parent
598a10bc28
commit
5a6d6c4d13
117 changed files with 1928 additions and 1928 deletions
|
@ -26,7 +26,7 @@ The length of a string can be constrained:
|
|||
```
|
||||
|
||||
#### [Regex](Regex.md)
|
||||
The `pattern` keyword is used to restrict a string to a particular [regular expression](Regex.md)
|
||||
The `pattern` keyword is used to restrict a string to a particular [regular expression](Regex.md)
|
||||
```json
|
||||
{
|
||||
"type": "string",
|
||||
|
@ -43,45 +43,45 @@ Optionally, validator implementations can provide a configuration option to enab
|
|||
The following is the list of formats specified in the JSON Schema specification.
|
||||
|
||||
###### Dates and times
|
||||
Dates and times are represented in [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6). This is a subset of the date format also commonly known as [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
- `"date-time"`: Date and time together, for example, `2018-11-13T20:20:39+00:00`.
|
||||
- `"time"`: Time, for example, `20:20:39+00:00`
|
||||
- `"date"`: Date, for example, `2018-11-13`.
|
||||
- `"duration"`: A duration as defined by the [ISO 8601 ABNF for "duration"](https://datatracker.ietf.org/doc/html/rfc3339#appendix-A). For example, `P3D` expresses a duration of 3 days.
|
||||
Dates and times are represented in [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6). This is a subset of the date format also commonly known as [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html).
|
||||
- `"date-time"`: Date and time together, for example, `2018-11-13T20:20:39+00:00`.
|
||||
- `"time"`: Time, for example, `20:20:39+00:00`
|
||||
- `"date"`: Date, for example, `2018-11-13`.
|
||||
- `"duration"`: A duration as defined by the [ISO 8601 ABNF for "duration"](https://datatracker.ietf.org/doc/html/rfc3339#appendix-A). For example, `P3D` expresses a duration of 3 days.
|
||||
|
||||
###### [Email](../internet/eMail.md) addresses
|
||||
- `"email"`: Internet email address, see [RFC 5321, section 4.1.2](http://tools.ietf.org/html/rfc5321#section-4.1.2).
|
||||
- `"idn-email"`: The internationalized form of an Internet email address, see [RFC 6531](https://tools.ietf.org/html/rfc6531).
|
||||
- `"email"`: Internet email address, see [RFC 5321, section 4.1.2](http://tools.ietf.org/html/rfc5321#section-4.1.2).
|
||||
- `"idn-email"`: The internationalized form of an Internet email address, see [RFC 6531](https://tools.ietf.org/html/rfc6531).
|
||||
|
||||
###### Hostnames
|
||||
- `"hostname"`: Internet host name, see [RFC 1123, section 2.1](https://datatracker.ietf.org/doc/html/rfc1123#section-2.1).
|
||||
- `"idn-hostname"`: An internationalized Internet host name, see [RFC5890, section 2.3.2.3](https://tools.ietf.org/html/rfc5890#section-2.3.2.3).
|
||||
- `"hostname"`: Internet host name, see [RFC 1123, section 2.1](https://datatracker.ietf.org/doc/html/rfc1123#section-2.1).
|
||||
- `"idn-hostname"`: An internationalized Internet host name, see [RFC5890, section 2.3.2.3](https://tools.ietf.org/html/rfc5890#section-2.3.2.3).
|
||||
|
||||
###### IP Addresses
|
||||
- `"ipv4"`: IPv4 address, according to dotted-quad ABNF syntax as defined in [RFC 2673, section 3.2](http://tools.ietf.org/html/rfc2673#section-3.2).
|
||||
- `"ipv6"`: IPv6 address, as defined in [RFC 2373, section 2.2](http://tools.ietf.org/html/rfc2373#section-2.2).
|
||||
- `"ipv4"`: IPv4 address, according to dotted-quad ABNF syntax as defined in [RFC 2673, section 3.2](http://tools.ietf.org/html/rfc2673#section-3.2).
|
||||
- `"ipv6"`: IPv6 address, as defined in [RFC 2373, section 2.2](http://tools.ietf.org/html/rfc2373#section-2.2).
|
||||
|
||||
###### Resource identifiers
|
||||
- `"uuid"`: A Universally Unique Identifier as defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122). Example: `3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a`
|
||||
- `"uri"`: A universal resource identifier (URI), according to [RFC3986](http://tools.ietf.org/html/rfc3986).
|
||||
- `"uri-reference"`: A URI Reference (either a URI or a relative-reference), according to [RFC3986, section 4.1](http://tools.ietf.org/html/rfc3986#section-4.1).
|
||||
- `"iri"`: The internationalized equivalent of a "uri", according to [RFC3987](https://tools.ietf.org/html/rfc3987).
|
||||
- `"iri-reference"`: New in draft 7The internationalized equivalent of a "uri-reference", according to [RFC3987](https://tools.ietf.org/html/rfc3987)
|
||||
- `"uuid"`: A Universally Unique Identifier as defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122). Example: `3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a`
|
||||
- `"uri"`: A universal resource identifier (URI), according to [RFC3986](http://tools.ietf.org/html/rfc3986).
|
||||
- `"uri-reference"`: A URI Reference (either a URI or a relative-reference), according to [RFC3986, section 4.1](http://tools.ietf.org/html/rfc3986#section-4.1).
|
||||
- `"iri"`: The internationalized equivalent of a "uri", according to [RFC3987](https://tools.ietf.org/html/rfc3987).
|
||||
- `"iri-reference"`: New in draft 7The internationalized equivalent of a "uri-reference", according to [RFC3987](https://tools.ietf.org/html/rfc3987)
|
||||
|
||||
If the values in the schema have the ability to be relative to a particular source path (such as a link from a webpage), it is generally better practice to use `"uri-reference"` (or `"iri-reference"`) rather than `"uri"` (or `"iri"`). `"uri"` should only be used when the path must be absolute.
|
||||
If the values in the schema have the ability to be relative to a particular source path (such as a link from a webpage), it is generally better practice to use `"uri-reference"` (or `"iri-reference"`) rather than `"uri"` (or `"iri"`). `"uri"` should only be used when the path must be absolute.
|
||||
|
||||
###### URI template
|
||||
- `"uri-template"`: A URI Template (of any level) according to [RFC6570](https://tools.ietf.org/html/rfc6570). If you don't already know what a URI Template is, you probably don't need this value.
|
||||
- `"uri-template"`: A URI Template (of any level) according to [RFC6570](https://tools.ietf.org/html/rfc6570). If you don't already know what a URI Template is, you probably don't need this value.
|
||||
|
||||
###### JSON Pointer
|
||||
- `"json-pointer"`: A JSON Pointer, according to [RFC6901](https://tools.ietf.org/html/rfc6901). There is more discussion on the use of JSON Pointer within JSON Schema in [Structuring a complex schema](https://json-schema.org/understanding-json-schema/structuring). Note that this should be used only when the entire string contains only JSON Pointer content, e.g. `/foo/bar`. JSON Pointer URI fragments, e.g. `#/foo/bar/` should use `"uri-reference"`.
|
||||
- `"relative-json-pointer"`: A [relative JSON pointer](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01).
|
||||
- `"json-pointer"`: A JSON Pointer, according to [RFC6901](https://tools.ietf.org/html/rfc6901). There is more discussion on the use of JSON Pointer within JSON Schema in [Structuring a complex schema](https://json-schema.org/understanding-json-schema/structuring). Note that this should be used only when the entire string contains only JSON Pointer content, e.g. `/foo/bar`. JSON Pointer URI fragments, e.g. `#/foo/bar/` should use `"uri-reference"`.
|
||||
- `"relative-json-pointer"`: A [relative JSON pointer](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01).
|
||||
|
||||
###### Regular Expressions
|
||||
- `"regex"`: A [regular expression](Regex.md), which should be valid according to the [ECMA 262](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/) dialect.
|
||||
- `"regex"`: A [regular expression](Regex.md), which should be valid according to the [ECMA 262](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/) dialect.
|
||||
|
||||
### `integer`
|
||||
The `integer` type is used for integral numbers. JSON does not have distinct types for integers and floating-point values. Therefore, the presence or absence of a decimal point is not enough to distinguish between integers and non-integers. For example, `1` and `1.0` are two ways to represent the same value in JSON. JSON Schema considers that value an integer no matter which representation was used.
|
||||
The `integer` type is used for integral numbers. JSON does not have distinct types for integers and floating-point values. Therefore, the presence or absence of a decimal point is not enough to distinguish between integers and non-integers. For example, `1` and `1.0` are two ways to represent the same value in JSON. JSON Schema considers that value an integer no matter which representation was used.
|
||||
|
||||
For differencing float and integer values these types can be used.
|
||||
```json
|
||||
|
@ -90,7 +90,7 @@ For differencing float and integer values these types can be used.
|
|||
```
|
||||
|
||||
#### Multiples
|
||||
Numbers can be restricted to a multiple of a given number, using the `multipleOf` keyword. It may be set to any positive number.
|
||||
Numbers can be restricted to a multiple of a given number, using the `multipleOf` keyword. It may be set to any positive number.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ Numbers can be restricted to a multiple of a given number, using the `multipleO
|
|||
```
|
||||
|
||||
#### Range
|
||||
Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range).
|
||||
Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range).
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ Objects are the mapping type in [JSON](../files/JSON.md). They map "keys" to "va
|
|||
```
|
||||
|
||||
#### Properties
|
||||
The properties (key-value pairs) on an object are defined using the `properties` keyword. The value of `properties` is an object, where each key is the name of a property and each value is a schema used to validate that property. Any property that doesn't match any of the property names in the `properties` keyword is ignored by this keyword.
|
||||
The properties (key-value pairs) on an object are defined using the `properties` keyword. The value of `properties` is an object, where each key is the name of a property and each value is a schema used to validate that property. Any property that doesn't match any of the property names in the `properties` keyword is ignored by this keyword.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ The properties (key-value pairs) on an object are defined using the `properties
|
|||
```
|
||||
|
||||
#### Pattern Properties
|
||||
Sometimes you want to say that, given a particular kind of property name, the value should match a particular schema. That's where `patternProperties` comes in: it maps regular expressions to schemas. If a property name matches the given [regular expression](Regex.md), the property value must validate against the corresponding schema.
|
||||
Sometimes you want to say that, given a particular kind of property name, the value should match a particular schema. That's where `patternProperties` comes in: it maps regular expressions to schemas. If a property name matches the given [regular expression](Regex.md), the property value must validate against the corresponding schema.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -145,9 +145,9 @@ Sometimes you want to say that, given a particular kind of property name, the va
|
|||
```
|
||||
|
||||
#### Additional Properties
|
||||
The `additionalProperties` keyword is used to control the handling of extra stuff, that is, 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 `additionalProperties` keyword is used to control the handling of extra stuff, that is, 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 value of the `additionalProperties` keyword is a schema that will be used to validate any properties in the instance that are not matched by `properties` or `patternProperties`. Setting the `additionalProperties` schema to `false` means no additional properties will be allowed.
|
||||
The value of the `additionalProperties` keyword is a schema that will be used to validate any properties in the instance that are not matched by `properties` or `patternProperties`. Setting the `additionalProperties` schema to `false` means no additional properties will be allowed.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ The value of the `additionalProperties` keyword is a schema that will be used
|
|||
```
|
||||
|
||||
#### Required Properties
|
||||
By default, the properties defined by the `properties` keyword are not required. However, one can provide a list of required properties using the `required` keyword.
|
||||
By default, the properties defined by the `properties` keyword are not required. However, one can provide a list of required properties using the `required` keyword.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ The names of properties can be validated against a schema, irrespective of their
|
|||
```
|
||||
|
||||
#### Size
|
||||
The number of properties on an object can be restricted using the `minProperties` and `maxProperties` keywords. Each of these must be a non-negative integer.
|
||||
The number of properties on an object can be restricted using the `minProperties` and `maxProperties` keywords. Each of these must be a non-negative integer.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ Arrays are used for ordered elements. In [JSON](../files/JSON.md), each element
|
|||
```
|
||||
|
||||
#### Items
|
||||
List validation is useful for arrays of arbitrary length where each item matches the same schema. For this kind of array, set the `items` keyword to a single schema that will be used to validate all of the items in the array.
|
||||
List validation is useful for arrays of arbitrary length where each item matches the same schema. For this kind of array, set the `items` keyword to a single schema that will be used to validate all of the items in the array.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -235,7 +235,7 @@ Tuple validation is useful when the array is a collection of items where each ha
|
|||
```
|
||||
|
||||
#### Additional Items
|
||||
The `items` keyword can be used to control whether it's valid to have additional items in a tuple beyond what is defined in `prefixItems`. The value of the `items` keyword is a schema that all additional items must pass in order for the keyword to validate.
|
||||
The `items` keyword can be used to control whether it's valid to have additional items in a tuple beyond what is defined in `prefixItems`. The value of the `items` keyword is a schema that all additional items must pass in order for the keyword to validate.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -251,13 +251,13 @@ The `items` keyword can be used to control whether it's valid to have addition
|
|||
```
|
||||
|
||||
#### Unevaluated Items
|
||||
The `unevaluatedItems` keyword is useful mainly when you want to add or disallow extra items to an array.
|
||||
The `unevaluatedItems` keyword is useful mainly when you want to add or disallow extra items to an array.
|
||||
|
||||
`unevaluatedItems` applies to any values not evaluated by an `items`, `prefixItems`, or `contains` keyword. Just as `unevaluatedProperties` affects only **properties** in an object, `unevaluatedItems` affects only **items** in an array.
|
||||
`unevaluatedItems` applies to any values not evaluated by an `items`, `prefixItems`, or `contains` keyword. Just as `unevaluatedProperties` affects only **properties** in an object, `unevaluatedItems` affects only **items** in an array.
|
||||
|
||||
Watch out! The word "unevaluated" _does not mean_ "not evaluated by `items`, `prefixItems`, or `contains`." "Unevaluated" means "not successfully evaluated", or "does not evaluate to true".
|
||||
Watch out! The word "unevaluated" _does not mean_ "not evaluated by `items`, `prefixItems`, or `contains`." "Unevaluated" means "not successfully evaluated", or "does not evaluate to true".
|
||||
|
||||
Like with `items`, if you set `unevaluatedItems` to `false`, you can disallow extra items in the array.
|
||||
Like with `items`, if you set `unevaluatedItems` to `false`, you can disallow extra items in the array.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ Like with `items`, if you set `unevaluatedItems` to `false`, you can disallo
|
|||
```
|
||||
|
||||
#### Contains
|
||||
While the `items` schema must be valid for every item in the array, the `contains` schema only needs to validate against one or more items in the array.
|
||||
While the `items` schema must be valid for every item in the array, the `contains` schema only needs to validate against one or more items in the array.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ While the `items` schema must be valid for every item in the array, the `cont
|
|||
```
|
||||
|
||||
#### minContains / maxContains
|
||||
`minContains` and `maxContains` can be used with `contains` to further specify how many times a schema matches a `contains` constraint. These keywords can be any non-negative number including zero.
|
||||
`minContains` and `maxContains` can be used with `contains` to further specify how many times a schema matches a `contains` constraint. These keywords can be any non-negative number including zero.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ The length of the array can be specified using the minItems and maxItems keyword
|
|||
```
|
||||
|
||||
#### Uniqueness
|
||||
A schema can ensure that each of the items in an array is unique. Simply set the `uniqueItems` keyword to `true`.
|
||||
A schema can ensure that each of the items in an array is unique. Simply set the `uniqueItems` keyword to `true`.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ A schema can ensure that each of the items in an array is unique. Simply set the
|
|||
```
|
||||
|
||||
### `boolean`
|
||||
The boolean type matches only two special values: `true` and `false`. Note that values that _evaluate_ to `true` or `false`, such as 1 and 0, are not accepted by the schema.
|
||||
The boolean type matches only two special values: `true` and `false`. Note that values that _evaluate_ to `true` or `false`, such as 1 and 0, are not accepted by the schema.
|
||||
|
||||
```json
|
||||
{ "type": "boolean" }
|
||||
|
@ -332,15 +332,15 @@ When a schema specifies a type of null, it has only one acceptable value: null.
|
|||
## Annotations
|
||||
JSON Schema includes a few keywords, that aren't strictly used for validation, but are used to describe parts of a schema. None of these "annotation" keywords are required, but they are encouraged for good practice, and can make your schema "self-documenting".
|
||||
|
||||
The `title` and `description` keywords must be strings. A "title" will preferably be short, whereas a "description" will provide a more lengthy explanation about the purpose of the data described by the schema.
|
||||
The `title` and `description` keywords must be strings. A "title" will preferably be short, whereas a "description" will provide a more lengthy explanation about the purpose of the data described by the schema.
|
||||
|
||||
The `default` keyword specifies a default value. This value is not used to fill in missing values during the validation process. Non-validation tools such as documentation generators or form generators may use this value to give hints to users about how to use a value. However, `default` is typically used to express that if a value is missing, then the value is semantically the same as if the value was present with the default value. The value of `default` should validate against the schema in which it resides, but that isn't required.
|
||||
The `default` keyword specifies a default value. This value is not used to fill in missing values during the validation process. Non-validation tools such as documentation generators or form generators may use this value to give hints to users about how to use a value. However, `default` is typically used to express that if a value is missing, then the value is semantically the same as if the value was present with the default value. The value of `default` should validate against the schema in which it resides, but that isn't required.
|
||||
|
||||
The `examples` keyword is a place to provide an array of examples that validate against the schema. This isn't used for validation, but may help with explaining the effect and purpose of the schema to a reader. Each entry should validate against the schema in which it resides, but that isn't strictly required. There is no need to duplicate the `default` value in the `examples` array, since `default` will be treated as another example.
|
||||
The `examples` keyword is a place to provide an array of examples that validate against the schema. This isn't used for validation, but may help with explaining the effect and purpose of the schema to a reader. Each entry should validate against the schema in which it resides, but that isn't strictly required. There is no need to duplicate the `default` value in the `examples` array, since `default` will be treated as another example.
|
||||
|
||||
The boolean keywords `readOnly` and `writeOnly` are typically used in an API context. `readOnly` indicates that a value should not be modified. It could be used to indicate that a `PUT` request that changes a value would result in a `400 Bad Request` response. `writeOnly` indicates that a value may be set, but will remain hidden. In could be used to indicate you can set a value with a `PUT` request, but it would not be included when retrieving that record with a `GET` request.
|
||||
The boolean keywords `readOnly` and `writeOnly` are typically used in an API context. `readOnly` indicates that a value should not be modified. It could be used to indicate that a `PUT` request that changes a value would result in a `400 Bad Request` response. `writeOnly` indicates that a value may be set, but will remain hidden. In could be used to indicate you can set a value with a `PUT` request, but it would not be included when retrieving that record with a `GET` request.
|
||||
|
||||
The `deprecated` keyword is a boolean that indicates that the instance value the keyword applies to should not be used and may be removed in the future.
|
||||
The `deprecated` keyword is a boolean that indicates that the instance value the keyword applies to should not be used and may be removed in the future.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -358,7 +358,7 @@ The `deprecated` keyword is a boolean that indicates that the instance value t
|
|||
```
|
||||
|
||||
## Enumerated values
|
||||
The `enum` keyword is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique.
|
||||
The `enum` keyword is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -367,7 +367,7 @@ The `enum` keyword is used to restrict a value to a fixed set of values. It mu
|
|||
```
|
||||
|
||||
## Constant Values
|
||||
The `const` keyword is used to restrict a value to a single value.
|
||||
The `const` keyword is used to restrict a value to a single value.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -383,17 +383,17 @@ The `const` keyword is used to restrict a value to a single value.
|
|||
JSON schema has a set of keywords to describe and optionally validate non-JSON data stored inside [JSON](../files/JSON.md) strings. Since it would be difficult to write validators for many media types, JSON schema validators are not required to validate the contents of [JSON](../files/JSON.md) strings based on these keywords. However, these keywords are still useful for an application that consumes validated [JSON](../files/JSON.md).
|
||||
|
||||
### contentMediaType
|
||||
The `contentMediaType` keyword specifies the [MIME](../files/MIME.md) type of the contents of a string, as described in [RFC 2046](https://tools.ietf.org/html/rfc2046). There is a list of [MIME types officially registered by the IANA](http://www.iana.org/assignments/media-types/media-types.xhtml), but the set of types supported will be application and operating system dependent. Mozilla Developer Network also maintains a [shorter list of MIME types that are important for the web](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types)
|
||||
The `contentMediaType` keyword specifies the [MIME](../files/MIME.md) type of the contents of a string, as described in [RFC 2046](https://tools.ietf.org/html/rfc2046). There is a list of [MIME types officially registered by the IANA](http://www.iana.org/assignments/media-types/media-types.xhtml), but the set of types supported will be application and operating system dependent. Mozilla Developer Network also maintains a [shorter list of MIME types that are important for the web](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types)
|
||||
|
||||
### contentEncoding
|
||||
The `contentEncoding` keyword specifies the encoding used to store the contents, as specified in [RFC 2054, part 6.1](https://tools.ietf.org/html/rfc2045) and [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648).
|
||||
The `contentEncoding` keyword specifies the encoding used to store the contents, as specified in [RFC 2054, part 6.1](https://tools.ietf.org/html/rfc2045) and [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648).
|
||||
|
||||
The acceptable values are `7bit`, `8bit`, `binary`, `quoted-printable`, `base16`, `base32`, and `base64`. If not specified, the encoding is the same as the containing [JSON](../files/JSON.md) document.
|
||||
The acceptable values are `7bit`, `8bit`, `binary`, `quoted-printable`, `base16`, `base32`, and `base64`. If not specified, the encoding is the same as the containing [JSON](../files/JSON.md) document.
|
||||
|
||||
Without getting into the low-level details of each of these encodings, there are really only two options useful for modern usage:
|
||||
|
||||
- If the content is encoded in the same encoding as the enclosing [JSON](../files/JSON.md) document (which for practical purposes, is almost always UTF-8), leave `contentEncoding` unspecified, and include the content in a string as-is. This includes text-based content types, such as `text/html` or `application/xml`.
|
||||
- If the content is binary data, set `contentEncoding` to `base64` and encode the contents using [Base64](https://tools.ietf.org/html/rfc4648). This would include many image types, such as `image/png` or audio types, such as `audio/mpeg`.
|
||||
- If the content is encoded in the same encoding as the enclosing [JSON](../files/JSON.md) document (which for practical purposes, is almost always UTF-8), leave `contentEncoding` unspecified, and include the content in a string as-is. This includes text-based content types, such as `text/html` or `application/xml`.
|
||||
- If the content is binary data, set `contentEncoding` to `base64` and encode the contents using [Base64](https://tools.ietf.org/html/rfc4648). This would include many image types, such as `image/png` or audio types, such as `audio/mpeg`.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -412,7 +412,7 @@ Without getting into the low-level details of each of these encodings, there are
|
|||
|
||||
## Conditional Schemas
|
||||
### dependentRequired
|
||||
The `dependentRequired` keyword conditionally requires that certain properties must be present if a given property is present in an object. For example, suppose we have a schema representing a customer. If you have their credit card number, you also want to ensure you have a billing address. If you don't have their credit card number, a billing address would not be required. We represent this dependency of one property on another using the `dependentRequired` keyword. The value of the `dependentRequired` keyword is an object. Each entry in the object maps from the name of a property, _p_, to an array of strings listing properties that are required if _p_ is present.
|
||||
The `dependentRequired` keyword conditionally requires that certain properties must be present if a given property is present in an object. For example, suppose we have a schema representing a customer. If you have their credit card number, you also want to ensure you have a billing address. If you don't have their credit card number, a billing address would not be required. We represent this dependency of one property on another using the `dependentRequired` keyword. The value of the `dependentRequired` keyword is an object. Each entry in the object maps from the name of a property, _p_, to an array of strings listing properties that are required if _p_ is present.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -430,7 +430,7 @@ The `dependentRequired` keyword conditionally requires that certain properties
|
|||
```
|
||||
|
||||
### dependentSchemas
|
||||
The `dependentSchemas` keyword conditionally applies a subschema when a given property is present. This schema is applied in the same way [allOf](https://json-schema.org/understanding-json-schema/reference/combining#allof) applies schemas. Nothing is merged or extended. Both schemas apply independently.
|
||||
The `dependentSchemas` keyword conditionally applies a subschema when a given property is present. This schema is applied in the same way [allOf](https://json-schema.org/understanding-json-schema/reference/combining#allof) applies schemas. Nothing is merged or extended. Both schemas apply independently.
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue