ajv-validator / ajv-validator/ajv-merge-patch
Nested merge and patch
- Linguagem predominante
- JavaScript
- Estrelas
- 47
- Forks
- 19
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.