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

$defs doesn't work, but definitions does #115

Closed
ieure opened this issue Jan 4, 2022 · 1 comment
Closed

$defs doesn't work, but definitions does #115

ieure opened this issue Jan 4, 2022 · 1 comment

Comments

@ieure
Copy link

ieure commented Jan 4, 2022

I'm not sure if I'm doing something wrong here or what. I'm using version 0.2.1 of this library.

I have this schema, which declares that it's draft 2019-09, and uses $defs, as draft 2019-09 requires. However, jsonschema v0.2.1 fails to codegen, saying it can't find the reference.

Here's the schema. I've confirmed that it validates against the draft 2019-09 metaschema:

{
    "$schema": "https://json-schema.org/draft/2019-09/schema",

    "$defs": {
        "name": {
            "title": "Name",
            "type": "string",
            "pattern": "^[A-Z][a-z]+$"
        }
    },

    "type": "object",
    "properties": {
        "name": {
            "$ref": "#/$defs/name"
        }
    },
    "required": ["name"]
}

Codegen fails with this error:

Failure generating structs:  processReference: reference "#/$defs/name" not found at "#/properties/name"

If I change $defs to definitions, it works fine:

{
    "$schema": "https://json-schema.org/draft/2019-09/schema",

    "definitions": {
        "name": {
            "title": "Name",
            "type": "string",
            "pattern": "^[A-Z][a-z]+$"
        }
    },

    "type": "object",
    "properties": {
        "name": {
            "$ref": "#/definitions/name"
        }
    },
    "required": ["name"]
}

Given that there are several other issues with the exact opposite problem (#97, #79, #68 — all using <= draft 7 definitions, which don't work), I have no idea why this is happening.

@ieure
Copy link
Author

ieure commented Jan 4, 2022

Wrong project, I'm a dummy.

@ieure ieure closed this as completed Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant