ajv-validator / ajv-validator/ajv-merge-patch
Nested merge and patch
- Vorherrschende Sprache
- JavaScript
- Sterne
- 47
- Forks
- 19
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi,
I'm not sure if this is an issue with my understand of the spec or not. I understand merge a lot better than patch and so I'd like to use it where possible and then patch things I can't fix with merge. However, I'm having difficulty applying a patch to a schema who's source I apply a merge:
deliver.json
```json
{
"type": "object",
"definitions": {
"settings": {
"type": "object",
"properties": {
"country": {
"type": "array",
"items": { "type": "string" }
},
"client": {
"type": "array",
"items": {
"type": "string",
"enum": ["mobile", "desktop"]
}
}
},
"additionalProperties": false
}
},
"properties": {
"include": { "$ref": "#/definitions/settings" },
"exclude": { "$ref": "#/definitions/settings" },
"templateParameters": {
"type": "object",
"required": [],
"patternProperties": {
".*": { "type": "string" }
}
},
"expire": { "type": "string", "format": "date" }
},
"required": [],
"additionalProperties": false
}
```
and my new schema:
x.json
```json
{
"$patch": {
"source" : {
"$merge": {
"source": { "$ref": "deliver.json" },
"with": {
"properties": {
"templateParameters": {
"properties": {
"link": { "type": "string" }
},
"required": ["link"]
}
},
"required": ["templateParameters"]
}
}
},
"with": [{
"op": "replace",
"path": "/properties/include/properties/client/items",
"value": { "type": "string", "enum": [ "alpha", "bravo" ] }
}]
}
}
```
I get the error message:
```javascript
{ [OPERATION_PATH_UNRESOLVABLE: Cannot perform the operation at a path that does not exist]
message: 'Cannot perform the operation at a path that does not exist',
name: 'OPERATION_PATH_UNRESOLVABLE',
index: 0,
operation:
{ op: 'replace',
path: '/properties/include/properties/client/items',
value: { type: 'string', enum: [Array] } },
tree: { '$merge': { source: [Object], with: [Object] } } }
```
Is this expected? I'm not sure if this kind of thing is allowed under the specification but if it were then I think the order the transformations are applied would need to be altered.
Thanks
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.