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

Migrating doesn't change definitions in references #112

Closed
mikethecalamity opened this issue Feb 12, 2021 · 2 comments
Closed

Migrating doesn't change definitions in references #112

mikethecalamity opened this issue Feb 12, 2021 · 2 comments
Labels

Comments

@mikethecalamity
Copy link

mikethecalamity commented Feb 12, 2021

The migration changes definitions to $def at the top, but it does not change the references.

draft-04

{
    "type": "array",
    "items": { "$ref": "#/definitions/positiveInteger" },
    "definitions": {
        "positiveInteger": {
            "type": "integer",
            "exclusiveMinimum": 0
        }
    }
}

migration to draft-2019-09

{
    "type": "array",
    "items": { "$ref": "#/definitions/positiveInteger" },  #wrong
    "$defs": {
        "positiveInteger": {
            "type": "integer",
            "exclusiveMinimum": 0
        }
    }
}
@epoberezkin
Copy link
Member

That’s a problem indeed... No idea why I didn’t think about it.

@epoberezkin
Copy link
Member

Fixing this is not trivial - the problem is not only the complexity of traversing the schema, but deciding which references need to change - they may point to other files.

So if currently files are processed in isolation, they would have to be processed collectively to update the known references only (plus updating definitions may break some other dependencies of these schemas).

The good thing is that it is not necessary - they can just remain definitions - it is still supported in any draft. So the fix is to keep definitions as they are, without changing to $defs.

epoberezkin added a commit to ajv-validator/json-schema-migrate that referenced this issue Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants