Skip to content

Commit

Permalink
jsonschemavalidate: Add more fields to output object
Browse files Browse the repository at this point in the history
Will be used later to rewrite error messages in
Open-Telecoms-Data/cove-ofds#4
  • Loading branch information
odscjames committed Nov 9, 2022
1 parent 8c2dbd3 commit 05a1c8e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- JSONSchema validate:
- Add format checkers
- Add more fields to output object

## [0.3.0] - 2022-11-08

Expand Down
6 changes: 6 additions & 0 deletions libcoveofds/jsonschemavalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ def __init__(
self._path = json_schema_exceptions_validation_error.path
self._schema_path = json_schema_exceptions_validation_error.schema_path
self._validator = json_schema_exceptions_validation_error.validator
self._validator_value = json_schema_exceptions_validation_error.validator_value
self._data_ids = schema.extract_data_ids_from_data_and_path(
json_data, self._path
)
self._context = json_schema_exceptions_validation_error.context
self._instance = json_schema_exceptions_validation_error.instance

def json(self):
return {
Expand All @@ -41,4 +44,7 @@ def json(self):
"schema_path": list(self._schema_path),
"validator": self._validator,
"data_ids": self._data_ids,
"validator_value": self._validator_value,
"context": self._context,
"instance": self._instance,
}
5 changes: 4 additions & 1 deletion tests/fixtures/jsonschemavalidate/bad_uuid_1.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"validator": "format",
"data_ids": {
"network_id": "1"
}
},
"validator_value": "uuid",
"context": [],
"instance": "1"
}
]
5 changes: 4 additions & 1 deletion tests/fixtures/jsonschemavalidate/basic_1.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"data_ids": {
"network_id": "a096d627-72e1-4f9b-b129-951b1737bff4",
"node_id": "1"
}
},
"validator_value": "object",
"context": [],
"instance": "Somewhere, idunno"
}
]

0 comments on commit 05a1c8e

Please sign in to comment.