Continuing from my previous unresolved issue, I am using json-schema-faker
and json-server
and i am currently trying to reuse some data from my json schema.
I have found the property: jsonPath
from this page in Github which explains exactly what I am trying to do and what my problem is.
I am trying to test this property from my JavaScript application which generates these data and also from the json-schema-faker site which is the library I use. Using this property using any of the above ways, returns a random string instead of the id I am referring to ( "jsonPath": "$..properties.test.items.properties.id"
)
Validating using this site, causes no issues and the value I am trying to re-use is picked up correctly using the jsonPath
.
Is there anything I should import in my JavaScript code/mock data generator or what I am trying to do is not supported perhaps by the json-schema version?
Some of the paths I have tried to use are:
$..id
$..test.items.properties.id
$..test.id
This is my json schema:
{
"title": "teest",
"type": "object",
"required": [
"test"
],
"properties": {
"test": {
"type": "array",
"minItems": 1,
"maxItems": 3,
"uniqueItems": true,
"items": {
"type": "object",
"required": [
"id",
"samples"
],
"properties": {
"id": {
"type": "string",
"enum": [
"1,",
"2",
"3"
]
},
"samples": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"test2": {
"type": "string",
"jsonPath": "$..properties.test.items.properties.id"
}
}
}
}
}
}
}
}
}
I would appreciate any help with this as I can't find anything online, and I really don't want to mock these data using hard-coded values.