Open Tryking opened 5 years ago
{
"type": "object",
"properties": {
"employee": {
"$ref": "file:/Users/apiAutomation/schema/definitions.json#/definitions/employeeDetails"
}
}
}
Use file attribute and give the absolute path of your external json file. absolute path of my file : /Users/apiAutomation/schema/definitions.json Note: the path following the #(pound) symbol is the path of my employeeDetails in my definitions.json
{
"definitions": {
"employeeDetails": {
"$id": "#employeeDetails",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "number"
},
"id": {
"type": "number"
}
},
"required": [
"name",
"id"
]
}
}
}
Use $ref as below to refer the external json file:
schema.json
{ "type": "object", "properties": { "employee": { "$ref": "file:/Users/apiAutomation/schema/definitions.json#/definitions/employeeDetails" } } }
Use file attribute and give the absolute path of your external json file. absolute path of my file : /Users/apiAutomation/schema/definitions.json Note: the path following the #(pound) symbol is the path of my employeeDetails in my definitions.json
definitions.json
{ "definitions": { "employeeDetails": { "$id": "#employeeDetails", "type": "object", "additionalProperties": false, "properties": { "name": { "type": "string" }, "age": { "type": "number" }, "id": { "type": "number" } }, "required": [ "name", "id" ] } } }
I see, thank you.
But what if i want to give relative path , how to give that
How to reference other json file by using $ref?