From c796e69ad87f01a6e5138a82865b5be0738df1d0 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 19 Oct 2023 13:38:13 +0000 Subject: [PATCH 1/2] jsonschema: Output row for an array even if items property is missing https://github.com/OpenDataServices/sphinxcontrib-opendataservices-jsonschema/issues/56 --- CHANGELOG.md | 4 ++++ sphinxcontrib/jsonschema.py | 4 +++- tests/examples/basic.html | 13 +++++++++++++ tests/examples/basic/subdir/test.json | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2117d1b..2ab5fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Output row for an array even if items property is missing https://github.com/OpenDataServices/sphinxcontrib-opendataservices-jsonschema/issues/56 + ## [0.6.0] - 2023-08-31 ### Changed diff --git a/sphinxcontrib/jsonschema.py b/sphinxcontrib/jsonschema.py index 99b1689..1273e1b 100644 --- a/sphinxcontrib/jsonschema.py +++ b/sphinxcontrib/jsonschema.py @@ -430,7 +430,9 @@ def validations(self): def __iter__(self): if self.items is None: - return + # array object itself + array = Array(self.name, self.attributes, required=self.required, parent=self.parent) + yield array elif isinstance(self.items, dict): item = JSONSchema.instantiate(self.name + '/0', self.items, parent=self) diff --git a/tests/examples/basic.html b/tests/examples/basic.html index 3ab9b42..bf8ef65 100644 --- a/tests/examples/basic.html +++ b/tests/examples/basic.html @@ -83,6 +83,19 @@

None

+ + otherNames + +

array

+ + + + + + +

None

+ + diff --git a/tests/examples/basic/subdir/test.json b/tests/examples/basic/subdir/test.json index 502d08a..99ff91c 100644 --- a/tests/examples/basic/subdir/test.json +++ b/tests/examples/basic/subdir/test.json @@ -20,6 +20,10 @@ "items" : { "type" : "string" } + }, + "otherNames" : { + "meta_description": "Test an array that doesn't have items", + "type" : "array" } }, "required": ["otherContacts"], From 3f4c3069f367f63399bcedbdc976d045e63699f3 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Tue, 17 Oct 2023 19:35:16 +0000 Subject: [PATCH 2/2] Release 0.6.1 --- CHANGELOG.md | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ab5fa5..b0d309d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.6.1] - 2023-10-18 + ### Fixed - Output row for an array even if items property is missing https://github.com/OpenDataServices/sphinxcontrib-opendataservices-jsonschema/issues/56 diff --git a/setup.py b/setup.py index 2794572..c9e79a2 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='sphinxcontrib-opendataservices-jsonschema', - version='0.6.0', + version='0.6.1', url='https://github.com/OpenDataServices/sphinxcontrib-opendataservices-jsonschema', license='BSD', author='Takeshi KOMIYA & Open Data Services Co-operative',