pure version of lab5

This commit is contained in:
2026-11-10 07:44:19 +03:00
parent 2b9fb3f375
commit 7cd02da51d
31 changed files with 295 additions and 1866 deletions
+2 -2
View File
@@ -11,9 +11,9 @@ validate(spec)
from referencing import Registry, Resource
# The base URI resolves local #/components references inside examples.
resource = dict(spec, **{'$schema': 'https://json-schema.org/draft/2020-12/schema'})
registry = Registry().with_resource('urn:mtusi:openapi', Resource.from_contents(resource))
registry = Registry().with_resource('urn:messenger:openapi', Resource.from_contents(resource))
for name, example in json.loads((root/'contracts/examples.json').read_text()).items():
schema = {'$ref': 'urn:mtusi:openapi#/components/schemas/' + name}
schema = {'$ref': 'urn:messenger:openapi#/components/schemas/' + name}
Draft202012Validator(schema, registry=registry).validate(example)
for path in (root/'contracts').glob('*.schema.json'):
schema = json.loads(path.read_text())