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
64bf9a5e
Commit
64bf9a5e
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-907
: added faulty json to exception message
parent
428c2bb1
No related branches found
No related tags found
1 merge request
!127
Resolve TMSS-173 (2nd try)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/src/tmss/tmssapp/validation.py
+7
-2
7 additions, 2 deletions
SAS/TMSS/src/tmss/tmssapp/validation.py
with
7 additions
and
2 deletions
SAS/TMSS/src/tmss/tmssapp/validation.py
+
7
−
2
View file @
64bf9a5e
...
...
@@ -14,13 +14,18 @@ def validate_json_against_schema(json_string: str, schema: str):
if
type
(
schema
)
!=
str
:
schema
=
json
.
dumps
(
schema
)
# ensure the specification and schema are both valid json in the first place
try
:
# ensure the specification and schema are both valid json in the first place
json_object
=
json
.
loads
(
json_string
)
except
json
.
decoder
.
JSONDecodeError
as
e
:
raise
SchemaValidationException
(
"
Invalid JSON: %s
\n
%s
"
%
(
str
(
e
),
json_string
))
try
:
schema_object
=
json
.
loads
(
schema
)
except
json
.
decoder
.
JSONDecodeError
as
e
:
raise
SchemaValidationException
(
"
Invalid JSON: %s
"
%
str
(
e
))
raise
SchemaValidationException
(
"
Invalid JSON:
%s
\n
%s
"
%
(
str
(
e
)
,
schema
)
)
# now do the actual validation
try
:
jsonschema
.
validate
(
json_object
,
schema_object
)
except
jsonschema
.
ValidationError
as
e
:
...
...
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