diff --git a/extension_explorer/templates/extension_schema.html b/extension_explorer/templates/extension_schema.html index b2cc59e52..b8ede5fca 100644 --- a/extension_explorer/templates/extension_schema.html +++ b/extension_explorer/templates/extension_schema.html @@ -70,7 +70,7 @@

{% for field in properties.fields %} - + {{ field.path|replace('.', '.'|safe) }} @@ -117,7 +117,7 @@

{% endif %} - {{ field.definition_path }}{% if field.definition_path %}.{% endif %}{{ field.path|replace('.', '.'|safe) }} + {{ field.definition }}{% if field.definition %}.{% endif %}{{ field.path|replace('.', '.'|safe) }} {% if field.url %} diff --git a/extension_explorer/util.py b/extension_explorer/util.py index e952f7f90..86c63f824 100644 --- a/extension_explorer/util.py +++ b/extension_explorer/util.py @@ -248,22 +248,24 @@ def get_schema_tables(extension_version, lang): if field.schema is None: continue - key = field.definition_path + key = field.definition if not key: key = 'Release' if key not in tables: tables[key] = {'fields': []} - if field.definition_path in sources: - tables[key]['source'] = sources[field.definition_path] + if field.definition in sources: + tables[key]['source'] = sources[field.definition] + d = field.asdict( + sep='.', exclude=('name', 'deprecated', 'pointer', 'pattern', 'required', 'merge_by_id'), + ) with contextlib.suppress(jsonpointer.JsonPointerException): - _add_link_to_original_field(field, schema, sources) - - d = field.asdict(sep='.', exclude=('definition_pointer', 'pointer', 'required', 'deprecated')) + _, d['url'] = _add_link_to_original_field(field, schema, sources) d['title'] = field.schema.get('title', '') d['description'] = markdown(field.schema.get('description', '')) d['types'] = gettext(' or ').join(_get_types(field.schema, sources, extension_version, lang)) + tables[key]['fields'].append(d) return tables @@ -351,11 +353,10 @@ def _get_types(value, sources, extension_version, lang, n=1, field=None): def _add_link_to_original_field(field, schema, sources): original_field = jsonpointer.resolve_pointer(schema, field.pointer) - field_url_prefix = sources[field.definition_path]['field_url_prefix'] - if field_url_prefix: - field['url'] = field_url_prefix + field.pointer_components[-1] + field_url_prefix = sources[field.definition]['field_url_prefix'] + url = field_url_prefix + field.name if field_url_prefix else None - return original_field + return original_field, url def _codelist_url(basename, extension_version, lang): diff --git a/requirements.txt b/requirements.txt index 6c106b287..c0953b160 100644 --- a/requirements.txt +++ b/requirements.txt @@ -89,11 +89,11 @@ myst-parser==2.0.0 # via ocdsextensionregistry ocds-babel==0.3.5 # via ocdsextensionregistry -ocdsextensionregistry==0.5.0 +ocdsextensionregistry==0.6.5 # via # -r requirements.in # ocdskit -ocdskit==1.2.0 +ocdskit==1.3.0 # via -r requirements.in ocdsmerge==0.6.4 # via ocdskit diff --git a/requirements_dev.txt b/requirements_dev.txt index 6accfbc54..5f6d1df80 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -127,11 +127,11 @@ myst-parser==2.0.0 # via -r requirements.txt ocds-babel==0.3.5 # via -r requirements.txt -ocdsextensionregistry==0.5.0 +ocdsextensionregistry==0.6.5 # via # -r requirements.txt # ocdskit -ocdskit==1.2.0 +ocdskit==1.3.0 # via -r requirements.txt ocdsmerge==0.6.4 # via diff --git a/tests/test_util.py b/tests/test_util.py index c4088cda8..20c35080a 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -346,7 +346,7 @@ def test_get_schema_tables(client): 'Asset': { 'fields': [ { - 'definition_path': 'Asset', + 'definition': 'Asset', 'path': 'field', 'schema': release_schema['definitions']['Asset']['properties']['field'], 'multilingual': False, @@ -359,7 +359,7 @@ def test_get_schema_tables(client): 'Release': { 'fields': [ { - 'definition_path': '', + 'definition': '', 'path': 'titleOnly', 'schema': release_schema['properties']['titleOnly'], 'multilingual': True, @@ -368,7 +368,7 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', + 'definition': '', 'path': 'descriptionOnly', 'schema': release_schema['properties']['descriptionOnly'], 'multilingual': True, @@ -377,7 +377,7 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', + 'definition': '', 'path': 'typeOnly', 'schema': release_schema['properties']['typeOnly'], 'multilingual': False, @@ -386,7 +386,7 @@ def test_get_schema_tables(client): 'types': 'string', }, { - 'definition_path': '', + 'definition': '', 'path': 'ref', 'schema': release_schema['properties']['ref'], 'multilingual': False, @@ -395,7 +395,7 @@ def test_get_schema_tables(client): 'types': 'Asset object', }, { - 'definition_path': '', + 'definition': '', 'path': 'array', 'schema': release_schema['properties']['array'], 'multilingual': False, @@ -404,7 +404,7 @@ def test_get_schema_tables(client): 'types': 'array of strings / integers', }, { - 'definition_path': '', + 'definition': '', 'path': 'refArray', 'schema': release_schema['properties']['refArray'], 'multilingual': False, @@ -413,7 +413,7 @@ def test_get_schema_tables(client): 'types': 'array of Asset objects', }, { - 'definition_path': '', + 'definition': '', 'path': 'null', 'schema': release_schema['properties']['null'], 'multilingual': False, @@ -422,7 +422,7 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', + 'definition': '', 'path': 'external', 'schema': release_schema['properties']['external'], 'multilingual': False, @@ -431,7 +431,7 @@ def test_get_schema_tables(client): 'types': 'Value object', # noqa: E501 }, { - 'definition_path': '', + 'definition': '', 'path': 'field', 'schema': release_schema['properties']['field'], 'multilingual': False, @@ -440,7 +440,7 @@ def test_get_schema_tables(client): 'types': 'object', }, { - 'definition_path': '', + 'definition': '', 'path': 'field.subfield', 'schema': release_schema['properties']['field']['properties']['subfield'], 'multilingual': False, @@ -449,7 +449,7 @@ def test_get_schema_tables(client): 'types': 'object', }, { - 'definition_path': '', + 'definition': '', 'path': 'field.subfield.subsubfield', 'schema': release_schema['properties']['field']['properties']['subfield']['properties']['subsubfield'], # noqa: E501 'multilingual': False, @@ -458,7 +458,7 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', + 'definition': '', 'path': 'undeprecated', 'schema': release_schema['properties']['undeprecated'], 'multilingual': False, @@ -467,7 +467,7 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', + 'definition': '', 'path': 'deprecated', 'schema': release_schema['properties']['deprecated'], 'multilingual': False, @@ -476,8 +476,8 @@ def test_get_schema_tables(client): 'types': 'string', }, { - 'definition_path': '', - 'path': '(.*)', + 'definition': '', + 'path': '.*', 'schema': release_schema['patternProperties']['.*'], 'multilingual': False, 'title': 'Title', @@ -485,8 +485,8 @@ def test_get_schema_tables(client): 'types': 'string or integer', }, { - 'definition_path': '', - 'path': '(^typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)))', # noqa: E501 + 'definition': '', + 'path': '^typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))', # noqa: E501 'schema': {}, 'multilingual': False, 'title': '', @@ -494,8 +494,8 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', - 'path': '(typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$)', # noqa: E501 + 'definition': '', + 'path': 'typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$', # noqa: E501 'schema': {}, 'multilingual': False, 'title': '', @@ -503,8 +503,8 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': '', - 'path': '(typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)))', # noqa: E501 + 'definition': '', + 'path': 'typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))', # noqa: E501 'schema': {}, 'multilingual': False, 'title': '', @@ -521,7 +521,7 @@ def test_get_schema_tables(client): 'Tender': { 'fields': [ { - 'definition_path': 'Tender', + 'definition': 'Tender', 'path': 'field', 'schema': {}, 'multilingual': False, @@ -530,7 +530,7 @@ def test_get_schema_tables(client): 'types': '', }, { - 'definition_path': 'Tender', + 'definition': 'Tender', 'path': 'title', 'schema': {'title': 'Replacement'}, 'multilingual': False, @@ -549,7 +549,7 @@ def test_get_schema_tables(client): 'Location': { 'fields': [ { - 'definition_path': 'Location', + 'definition': 'Location', 'path': 'field', 'schema': {'type': 'string'}, 'multilingual': False, @@ -558,7 +558,7 @@ def test_get_schema_tables(client): 'types': 'string', }, { - 'definition_path': 'Location', + 'definition': 'Location', 'path': 'geometry', 'schema': {'title': 'Replacement'}, 'multilingual': False, @@ -604,7 +604,7 @@ def test_get_schema_tables_mixed_array_success(client): 'Release': { 'fields': [ { - 'definition_path': '', + 'definition': '', 'path': 'nullArray', 'schema': schema['properties']['nullArray'], 'multilingual': False,