question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested meta schema validates with unexpected errors (no additional properties allowed)

See original GitHub issue

Dear json-editors,

Expected Behaviour

I try implementing the meta schema into my project as part of the user interface. In this case, the meta schema is nested in another schema.

To be able to reference the definitions as a mayor part of the meta schema from the original json-editor files, I moved the definitions to the schemas top.

Actual Behaviour

For reasons I don’t understand the validation fails for most properties with the “no additional properties allowed” error.

Maybe you have an idea what exactly changes once the definitions are not on the same level as the meta schema property.

Steps to reproduce the behavior

I got rid of all the rest of the my schema and the problem persists. Here is the most basic example validating with the above error:

Direct link to example

this is how the meta schema was modified in short:

{
  "type": "object",
  "title": "Devices",
  "properties": {
    "device_schema": {
      "title": "Device Schema",
      "$ref": "#/definitions/schema",
      "properties": {
        "definitions": {
          "type": "object",
          "patternProperties": {
            ".*": {
              "$ref": "#/definitions/schema"
            }
          }
        }
      }
    }
  },
  "definitions": { ... } // all the definitions see json-editor meta schema
}

I use the meta_schema.json from the docs folder in json-editor version: 1.3.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Francimancommented, Sep 20, 2019

Hi, sorry for the huge delay, I saw one thing I don’t quite understand: In the schema you used for the json editor there is:

{
  "type": "object",
  "title": "Devices",
  "properties": {
    "device_schema": {
      "title": "device schema",
      "$ref": "#/definitions/schema",
      "properties": {
        "definitions": {
          "type": "object",
          "patternProperties": {
            ".*": {
              "$ref": "#/definitions/schema"
            }
          }
        }
      }
    }
  },
}

why did you put this fragment of schema before the metaschema? If I remove it, and then fill the json-editor with the json you used, it validates correctly.

As per the commit you referenced. I moved the additionalProperties: false into the oneOf branches, because having it in the schemaBase didn’t work, i.e. using unknown directives in the json-editor to create a schema was allowed, and I wanted to prevent things like this to validate:

{
    "type": "object",
    "title": "My Proof",
    "ujfallusa": true,
}

This schema uses the fictitious ujfallusa directive, which is not one of the directives listed in the Schema standard I referred to.

0reactions
machinaeXlassecommented, Oct 3, 2019

Hey! Thanks for having a look into this. Now its me being late, sorry.

I want to allow using the editor to create a schema for (inside) each “device” instance, that’s why I nested the meta schema into an object type.

Maybe in the end that’s not practical anyhow from a user point of view and creating the schema should be its own editor.

The way I did it just seemed more straightforward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make it clear that additionalProperties can only have ... - GitHub
JSON Schema allows for additionalProperties both a boolean or an object value. true is interpreted as "additional properties follow no ...
Read more >
JSON Schema puts null values when validation fails on ...
On top of that I tried to add .not(S.null()) to the schema in order to ensure that it throws the error if ends...
Read more >
Handling Validation Errors - python-jsonschema
When an invalid instance is encountered, a ValidationError will be raised or returned, depending on which method or function is used. exception jsonschema....
Read more >
Understanding JSON Schema
By default any additional properties are allowed. The value of the additionalProperties keyword is a schema that will be used to validate ......
Read more >
Understanding schema errors | HESA
Where the error message refers to an invalid child element it means that the fields within an entity in the file are not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found