Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ref to definitions inside “source” or “with” parts of $merge is not supported #28

Open
gallofeliz opened this issue Jan 7, 2019 · 5 comments

Comments

@gallofeliz
Copy link

Hi,

When the "with" object contains definitions (like '"$ref": "#/definitions/JwtConfig"'), ajv throws an error.

I need to move the "with" "definitions" property to the main object :

            {
                $merge: {
                    source
                    with
                },
                definitions
            }

I think it's an issue :)

Regards

@epoberezkin
Copy link
Member

Please add a specific example that you expect to work.

@gallofeliz
Copy link
Author

Something like :

var source = {
    type: 'object',
    properties: {
        parking: {
            type: 'object',
            properties: {
                cars: {
                    type: 'array',
                    items: { $ref: '#/definitions/car' }
                }
            }
        }
    },
    definitions: {
        car: {
            type: 'object',
            properties: {
                color: {
                    type: 'string'
                }
            }
        }
    }
}

var with = {
    type: 'object',
    properties: {
        cage: {
            type: 'object',
            properties: {
                birds: {
                    type: 'array',
                    items: { $ref: '#/definitions/bird' }
                }
            }
        }
    },
    definitions: {
        bird: {
            type: 'object',
            properties: {
                color: {
                    type: 'string'
                }
            }
        }
    }
}


var final = {
    $merge: {
        source,
        with
    }
}

@epoberezkin
Copy link
Member

yes, definitions have to be outside of the merge (and you can use merge inside definitions

@nwinch
Copy link

nwinch commented Nov 14, 2019

yes, definitions have to be outside of the merge (and you can use merge inside definitions

Is there an example anywhere of how this looks? I've tried the following (mock example) but it doesn't seem to work. Do I have definitions at the correct level (parallel to $merge) ?

{
  "id": "lixi-internal-request-custom",
  "$merge": {
    "source": { "$ref": "lixi-internal-request" },
    "with": {
      "properties": {}
    }
  },
  "definitions": {
    "ID": {
      "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9-_.]*$"
    }
  }
}

@gallofeliz
Copy link
Author

gallofeliz commented Nov 14, 2019 via email

@epoberezkin epoberezkin changed the title Definitions are not correctly handled $ref to definitions inside “source” or “with” parts of $merge are not supported Nov 23, 2019
@epoberezkin epoberezkin changed the title $ref to definitions inside “source” or “with” parts of $merge are not supported $ref to definitions inside “source” or “with” parts of $merge is not supported Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants