ajv-validator / ajv-validator/ajv-merge-patch

Nested merge and patch

オープン
#21 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
47
フォーク
19
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。