mirror of
https://github.com/openwrt/packages.git
synced 2025-12-19 17:11:21 +00:00
python-referencing: Add new package
From the README: An implementation-agnostic implementation of JSON reference resolution. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
committed by
Tianling Shen
parent
06231ce8cb
commit
728aac31bb
35
lang/python/python-referencing/test.sh
Normal file
35
lang/python/python-referencing/test.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ "$1" = python3-referencing ] || exit 0
|
||||
|
||||
python3 - << 'EOF'
|
||||
|
||||
from referencing import Registry, Resource
|
||||
import referencing.jsonschema
|
||||
|
||||
schema = Resource.from_contents( # Parse some contents into a 2020-12 JSON Schema
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "urn:example:a-202012-schema",
|
||||
"$defs": {
|
||||
"nonNegativeInteger": {
|
||||
"$anchor": "nonNegativeInteger",
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
registry = schema @ Registry() # Add the resource to a new registry
|
||||
|
||||
# From here forward, this would usually be done within a library wrapping this one,
|
||||
# like a JSON Schema implementation
|
||||
resolver = registry.resolver()
|
||||
resolved = resolver.lookup("urn:example:a-202012-schema#nonNegativeInteger")
|
||||
assert resolved.contents == {
|
||||
"$anchor": "nonNegativeInteger",
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
}
|
||||
|
||||
EOF
|
||||
Reference in New Issue
Block a user