Tools, FAQ, Tutorials:
JSON Type Unique Identifications
How to assign a unique identification to a JSON type in JSON Schema?
✍: FYIcenter.com
Using "definitions" and "$ref" properties allows to define JSON types
and reference them internally in the same JSON schema or externally
in another JSON schema.
You can also assign a unique identification to a JSON type with the "$id" property and reference them internally in the same JSON schema or externally in another JSON schema.
The "$id" property uses the URI syntax to assign unique identifications to JSON types in 3 different formats:
1. Absolute full URI - The JSON type is identified globally by the given URI. For example, the following JSON schema defines 2 JSON types named as "rating" and "yesNo" and assigns 2 full URIs as their "$id":
{
"definitions": {
"rating": {
"$id": "http://dev.fyicenter.com/JSON/schema.json#point",
"type": "integer",
},
"yesNo": {
"$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f",
"enum": ["yes", "no"]
}
},
...
}
2. Relative URI path - The JSON type is identified globally by the combination of the base URI of the parent type identification and the given URI path. For example, the following JSON schema defines a JSON type called "rating" and assign a URI path to it:
{
"$id": "http://dev.fyicenter.com/JSON/schema.json",
"definitions": {
"rating": {
"$id": "/JSON/survey.json#point",
"type": "integer",
}
},
...
}
The "rating" JSON type's global identification will be constructed by taking the URI base from the parent "$id" and concatenate with the given URI path: "http://dev.fyicenter.com/JSON/survey.json#point"
3. Internal bookmark - The JSON type is identified globally by the combination of the URI of the parent type identification and the given bookmark. For example, the following JSON schema defines a JSON type called "rating" and assign a bookmark to it:
{
"$id": "http://dev.fyicenter.com/JSON/schema.json",
"definitions": {
"rating": {
"$id": "#point",
"type": "integer",
}
},
...
}
The "rating" JSON type's global identification will be constructed by taking the URI from the parent "$id" and concatenate with the given bookmark: "http://dev.fyicenter.com/JSON/schema.json#point"
⇒ Implicit and Explicit ID of JSON Type
2017-08-20, ∼2411🔥, 0💬
Popular Posts:
How to use 'choose ... when ..." policy statements to control execution flows? If you want to contro...
How to use the "forward-request" Policy Statement to call the backend service for an Azure API servi...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...
What is Fabric CA (Certificate Authority)? Fabric CA (Certificate Authority) is a component of Hyper...
How to use the "set-body" Policy Statement for an Azure API service operation? The "set-body" Policy...