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

Overwriting properties from $ref does not work #55

Open
ypnos opened this issue Feb 22, 2021 · 1 comment
Open

Overwriting properties from $ref does not work #55

ypnos opened this issue Feb 22, 2021 · 1 comment
Labels

Comments

@ypnos
Copy link
Contributor

ypnos commented Feb 22, 2021

In the following example, we combine "$ref" with another key, here "properties".

Expected result: Validation returns "false" as modelVersion.major is > 2.
Observed result: Validation returns "true"

local schema = [[
  {
    "type": "object",
    "$defs": {
      "version": {
        "type": "object",
        "properties": {
          "major": {
            "type": "integer",
            "minimum": 0
          },
          "minor": {
            "type": "integer",
            "minimum": 0
          },
          "patch": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "major",
          "minor",
          "patch"
        ]
      }
    },
    "properties": {
      "modelVersion": {
        "$ref": "#/$defs/version",
        "properties": {
          "major": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1
          },
          "minor": {
            "type": "integer",
            "minimum": 0
          },
          "patch": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    }
  }
]]
local v = JsonSchema.generate_validator(Json.decode(schema), {match_pattern = function () end})
print(v(Json.decode([[
  {
    "modelVersion": {"major": 2, "minor": 2, "patch": 0}
  }
]])))
@membphis
Copy link
Contributor

https://github.com/jdesgats/ljsonschema

does it have this bug too? If yes, welcome to submit a PR to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants