Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common: Log warning for invalid JSON Schema in which "properties" values aren't JSON Schema #71

Merged
merged 3 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.20.2] - 2020-11-04

### Fixed

- Don't error when JSON schema "properties" values aren't JSON Schema, and log a warning instead https://github.com/OpenDataServices/lib-cove/pull/71

## [0.20.1] - 2020-10-27

### Fixed
Expand Down
11 changes: 11 additions & 0 deletions libcove/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fcntl
import functools
import json
import logging
import os
import re
from collections import OrderedDict
Expand Down Expand Up @@ -43,6 +44,8 @@
"array": "{}'{}' is not a JSON array",
}

logger = logging.getLogger(__name__)


def unique_ids(validator, ui, instance, schema, id_name="id"):
if ui and validator.is_type(instance, "array"):
Expand Down Expand Up @@ -1105,6 +1108,14 @@ def add_is_codelist(obj):
release.tag in core schema at the moment."""

for prop, value in obj.get("properties", {}).items():
if not isinstance(value, dict):
logger.warning(
"A 'properties' object contains a {!r} value that is not a JSON Schema: {!r}".format(
prop, value
)
)
continue

if "codelist" in value:
if "array" in value.get("type", ""):
value["items"]["isCodelist"] = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="libcove",
version="0.20.1",
version="0.20.2",
author="Open Data Services",
author_email="[email protected]",
url="https://github.com/OpenDataServices/lib-cove",
Expand Down