Skip to content

Commit

Permalink
Merge pull request #72 from jpmckinney/yield-all-fields
Browse files Browse the repository at this point in the history
schema_dict_fields_generator: JSON Schema is not guaranteed to set "type"
  • Loading branch information
Bjwebb authored Jan 20, 2021
2 parents fe96273 + c0d8ea0 commit 2bce73f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,19 @@ jobs:
pip install -e ./lib-cove-${{ matrix.cove }}/
pip list
- name: Test
- name: Test cove instance
run: |
cd cove-${{ matrix.cove }}
DJANGO_SETTINGS_MODULE=cove_project.settings py.test
cd ../lib-cove-${{ matrix.cove }}
- name: lib-cove-ocds requirements
if: matrix.cove == 'ocds'
run: |
# Upgrade Django for lib-cove-ocds tests, as they rely on some details
# of entity quoting that have changed
pip install --upgrade Django
- name: Test cove lib instance
run: |
cd lib-cove-${{ matrix.cove }}
py.test
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.20.3] - 2021-01-20

### Fixed

- JSON Schema is not guaranteed to set `type`, so look for `properties` or `items` instead (in `schema_dict_fields_generator`)

### Fixed

## [0.20.2] - 2020-11-04

### Fixed
Expand Down
13 changes: 5 additions & 8 deletions libcove/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import requests
from cached_property import cached_property
from flattentool import unflatten
from flattentool.schema import get_property_type_set
from jsonschema import FormatChecker, RefResolver
from jsonschema._utils import uniq
from jsonschema.compat import urlopen, urlsplit
Expand Down Expand Up @@ -228,15 +227,13 @@ def schema_dict_fields_generator(schema_dict):
for property_schema_dict in property_schema_dicts:
if not isinstance(property_schema_dict, dict):
continue
property_type_set = get_property_type_set(property_schema_dict)
if "object" in property_type_set:
if "properties" in property_schema_dict:
for field in schema_dict_fields_generator(property_schema_dict):
yield "/" + property_name + field
elif "array" in property_type_set:
fields = schema_dict_fields_generator(
property_schema_dict.get("items", {})
)
for field in fields:
elif "items" in property_schema_dict:
for field in schema_dict_fields_generator(
property_schema_dict["items"]
):
yield "/" + property_name + field
yield "/" + property_name
if "items" in schema_dict and isinstance(schema_dict["items"], dict):
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.2",
version="0.20.3",
author="Open Data Services",
author_email="[email protected]",
url="https://github.com/OpenDataServices/lib-cove",
Expand Down

0 comments on commit 2bce73f

Please sign in to comment.