1

My RefResolver and Validator script is

from jsonschema import RefResolver
from jsonschema.validators import validator_for
from tests.automation.io.helpers.loader import load_schema

base = load_schema('base.schema.json') # {"$schema": "http://json-schema.org/draft-07/schema#" }
definitions = load_schema('defination.schema.json') # https://jsonschema.dev/s/FZDbO
schema = load_schema('update.schema.json') # https://jsonschema.dev/s/lvLFa

schema_store = {
  base.get('$id','base.schema.json') : base,
  definitions.get('$id','defination.schema.json') : definitions,
  schema.get('$id','update.schema.json') : schema,
}

resolver = RefResolver.from_schema(base, store=schema_store)
Validator = validator_for(base)
validator = Validator(schema, resolver=resolver)

data = {
    "common_data": {
        "os_ip": "127.0.0.1",
        "os_user": "root",
        "os_pwd": "hello",
        "remote_os": "Windows"
    },
    "dup_file": "ad7a.exe"
}
validator.validate(data)

My JSON Schema looks like

base.schema.json => {"$schema": "http://json-schema.org/draft-07/schema#" }

defination.schema.json => https://jsonschema.dev/s/FZDbO

update.schema.json => https://jsonschema.dev/s/lvLFa

Getting error : jsonschema.exceptions.ValidationError: 'ad7a.exe' does not match '^(.*.)(bin)$'

Same thing I have tested https://json-schema.hyperjump.io/ it working perfectly fine , suspecting some issue with python-jsonschema only.

curiousguy
  • 3,212
  • 8
  • 39
  • 71
  • I don't see `'^(.*.)(bin)$'` in your schema anywhere. I don't think anyone can provide help for schemas they can't see. – Ether May 08 '21 at 04:14
  • @Ether thanks for the feedback. Actually I have mentioned JSON schema's beside the `load_schema` function as `#` for better understanding (live demo). I have updated the post also at the same time . – curiousguy May 08 '21 at 05:40
  • If anyone was able to reproduce the issue. I am thinking of using some other JSON schema validator. Suggestions pls. – curiousguy May 09 '21 at 03:12

0 Answers0