Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
37f11fee
Commit
37f11fee
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-493
: added method to get all the references from a schema
parent
1b67931b
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!324
Resolve TMSS-493
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
LCS/PyCommon/json_utils.py
+18
-0
18 additions, 0 deletions
LCS/PyCommon/json_utils.py
with
18 additions
and
0 deletions
LCS/PyCommon/json_utils.py
+
18
−
0
View file @
37f11fee
...
@@ -175,6 +175,24 @@ def resolved_refs(schema):
...
@@ -175,6 +175,24 @@ def resolved_refs(schema):
return
schema
return
schema
def
get_refs
(
schema
)
->
set
:
'''
return a set of all $refs in the schema
'''
refs
=
set
()
if
isinstance
(
schema
,
dict
):
for
key
,
value
in
schema
.
items
():
if
key
==
"
$ref
"
:
refs
.
add
(
value
)
else
:
refs
.
update
(
get_refs
(
value
))
if
isinstance
(
schema
,
list
):
for
item
in
schema
:
refs
.
update
(
get_refs
(
item
))
return
refs
def
validate_json_against_its_schema
(
json_object
:
dict
):
def
validate_json_against_its_schema
(
json_object
:
dict
):
'''
validate the give json object against its own schema (the URI/URL that its propery $schema points to)
'''
'''
validate the give json object against its own schema (the URI/URL that its propery $schema points to)
'''
schema_url
=
json_object
[
'
$schema
'
]
schema_url
=
json_object
[
'
$schema
'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment