Overriding json-schema from backend does not override definitions

Open
#93 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
json, python

Research direction

Start by inspecting merge_config and reproduce the behavior with the custom schema from the airos branch and the validation error example linked in the issue. Trace how the JSON schema and OrderedDict are combined, focusing on repeated definitions keys. Done means a backend definition replaces the default definition during merging and validation no longer reports the default alternatives.

Written by the indexing model from the issue text.

Description

bug

Let's say that we have a custom schema like in airos and that we print the schema, like it happens on a validation error report.

The interesting part is that redefined definitions do not override the default one as it can be read from the log

Against schema {'$ref': '#/definitions/ap_wireless_settings'}
{'proto': 'wpa2_personal', 'key': 'and-pizza-too'} is valid under each of
{'$ref': '#/definitions/encryption_wpa_personal'},
{'$ref': '#/definitions/encryption_wps'},
{'$ref': '#/definitions/encryption_wep'},
OrderedDict([('$ref', '#/definitions/encryption_none')]),
OrderedDict([('$ref', '#/definitions/encryption_wpa_personal')]),
OrderedDict([('$ref', '#/definitions/encryption_wpa_enterprise_sta')]),
{'$ref': '#/definitions/encryption_none'}

It seems that merge_config can merge a json-schema and OrderedDict but it treat the same definition as different elements.

Dominant language
Python
Stars
389
Forks
97
Avg merge
1d 14m
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openwisp/netjsonconfig

All issues in openwisp/netjsonconfig

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.