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

release-schema: add publisher field #1376

Merged
merged 9 commits into from
Aug 10, 2021
1 change: 1 addition & 0 deletions docs/history/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Per the [normative and non-normative content and changes policy](https://docs.go
* [#1165](https://github.com/open-contracting/standard/pull/1165) `statusDetails` to `Tender`, `Award` and `Contract`
* [#1125](https://github.com/open-contracting/standard/pull/1125) `Item.unit.weight`
* [#1326](https://github.com/open-contracting/standard/pull/1326) `links`
* [#1376](https://github.com/open-contracting/standard/pull/1376) `publisher`
* [#1208](https://github.com/open-contracting/standard/pull/1326) The estimated and maximum values of framework agreeemnts:
* `tender.maximumValue`. Previously, `tender.value` was used for the maximum value. However, this led to double-counting.
* `awards.maximumValue`. Previously, `awards.value` was used for the maximum value. However, this led to double-counting.
Expand Down
26 changes: 25 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,29 @@ def remove_metadata_and_extended_keywords(schema):
remove_metadata_and_extended_keywords(value)


def get_dereferenced_release_schema(schema, output=None):
"""
Returns the dereferenced release schema.
"""
# Without a deepcopy, changes to referenced objects are copied across referring objects. However, the deepcopy does
# not retain the `__reference__` property.
if not output:
output = deepcopy(schema)

if isinstance(schema, list):
for index, item in enumerate(schema):
get_dereferenced_release_schema(item, output[index])
elif isinstance(schema, dict):
for key, value in schema.items():
get_dereferenced_release_schema(value, output[key])
if hasattr(schema, '__reference__'):
for prop in schema.__reference__:
if prop != '$ref':
output[prop] = schema.__reference__[prop]

return output


def get_versioned_release_schema(schema):
"""
Returns the versioned release schema.
Expand Down Expand Up @@ -450,9 +473,10 @@ def pre_commit():
Update meta-schema.json, dereferenced-release-schema.json and versioned-release-validation-schema.json.
"""
release_schema = json_load('release-schema.json')
jsonref_release_schema = json_load('release-schema.json', jsonref)

json_dump('meta-schema.json', get_metaschema())
json_dump('dereferenced-release-schema.json', json_load('release-schema.json', jsonref))
json_dump('dereferenced-release-schema.json', get_dereferenced_release_schema(jsonref_release_schema))
json_dump('versioned-release-validation-schema.json', get_versioned_release_schema(release_schema))


Expand Down
Loading