Skip to content

Commit

Permalink
Merge pull request #71 from jpmckinney/fix-mtender-schema-bug
Browse files Browse the repository at this point in the history
common: Log warning for invalid JSON Schema in which "properties" values aren't JSON Schema
  • Loading branch information
Bjwebb committed Nov 4, 2020
2 parents 811298a + 16c2666 commit a3a321c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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="code@opendataservices.coop",
url="https://github.com/OpenDataServices/lib-cove",
Expand Down

0 comments on commit a3a321c

Please sign in to comment.