Skip to content
GitLab
Explore
Sign in
Register
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
122b16a6
Commit
122b16a6
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-272
: added validate_json_against_its_schema
parent
c1e991fd
No related branches found
No related tags found
1 merge request
!213
Resolve TMSS-272
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/src/tmss/tmssapp/validation.py
+6
-1
6 additions, 1 deletion
SAS/TMSS/src/tmss/tmssapp/validation.py
with
6 additions
and
1 deletion
SAS/TMSS/src/tmss/tmssapp/validation.py
+
6
−
1
View file @
122b16a6
...
...
@@ -4,13 +4,18 @@ from jsonschema import Draft6Validator, RefResolver
import
os
from
lofar.sas.tmss.tmss.exceptions
import
*
from
lofar.common.json_utils
import
add_defaults_to_json_object_for_schema
as
json_utils_add_defaults_to_json
import
requests
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
TMSS_SCHEMA_PATH
=
BASE_DIR
+
"
/tmssapp/schemas/
"
TMSS_COMMON_BASE_SCHEMA
=
"
base.json
"
# TODO: validation is not the correct name any more rename to schema.py or schema_utils.py ?
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)
'''
schema
=
json_object
[
'
$schema
'
]
return
validate_json_against_schema
(
json_object
,
requests
.
get
(
schema
).
text
)
def
validate_json_against_schema
(
json_string
:
str
,
schema
:
str
):
'''
validate the given json_string against the given schema.
If no exception if thrown, then the given json_string validates against the given 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