cvent/json-schema-deref-sync

mergeAdditionalProperties with lodash merge instead of Object.assign

Closed this issue · 1 comments

When using mergeAdditionalProperties option with a simple schema:

    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "Location":{
            "$ref":"mock.json#/definitions/Location",
            "properties": {
                "test":{
                    "type":"string"
                }
            }
        }
    } 

the property test overwrites the properties in the base schema. This is because Object.assign is used that only does a shallow copy. If replaced

if (options.mergeAdditionalProperties) {
            delete node.$ref
            newValue = Object.assign({}, newValue, node)
          }

with

            delete node.$ref
            newValue = _.merge(newValue, node)
          }

this would be solved.

Many thanks
Martin

Super. Thank you very much for such a quick response!
It seems however that it's a little bit more complicated. I'll close this issue and open another one.