diff options
author | F. Eugene Aumson <feuGeneA@users.noreply.github.com> | 2018-12-29 04:08:15 +0800 |
---|---|---|
committer | F. Eugene Aumson <feuGeneA@users.noreply.github.com> | 2018-12-29 04:08:15 +0800 |
commit | a3eab71908cd2e188438b4d411b7c426c874f0b2 (patch) | |
tree | dea7749d4e3ba236ac85ac4792c3fd453192cc0b /python-packages | |
parent | 7e12ae1bfce33dcd6812c10a0d03ff16bd4f3884 (diff) | |
download | dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.tar dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.tar.gz dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.tar.bz2 dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.tar.lz dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.tar.xz dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.tar.zst dexon-sol-tools-a3eab71908cd2e188438b4d411b7c426c874f0b2.zip |
Correct inconsistencies in JSON schema names
In both ref ID's and file names.
Diffstat (limited to 'python-packages')
-rw-r--r-- | python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py b/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py index 1752c5761..792e6041f 100644 --- a/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py +++ b/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py @@ -17,23 +17,7 @@ class _LocalRefResolver(jsonschema.RefResolver): jsonschema.RefResolver.__init__(self, "", "") @staticmethod - def _ref_to_file(ref: str) -> str: - """Translate a JSON schema ref to its corresponding file name. - - >>> _LocalRefResolver._ref_to_file("/addressSchema") - 'address_schema.json' - """ - _ref = ref.lstrip("/") - - # handle weird special cases - _ref = _ref.replace("ECSignature", "EcSignature") - if _ref.endswith("Schema"): - # strip off the Schema suffix - _ref = _ref[:-6] - - return f"{snakecase(_ref)}_schema.json" - - def resolve_from_url(self, url: str) -> str: + def resolve_from_url(url: str) -> str: """Resolve the given URL. :param url: a string representing the URL of the JSON schema to fetch. @@ -45,7 +29,7 @@ class _LocalRefResolver(jsonschema.RefResolver): return json.loads( resource_string( "zero_ex.json_schemas", - f"schemas/{_LocalRefResolver._ref_to_file(ref)}", + f"schemas/{snakecase(ref.lstrip('/'))}.json", ) ) @@ -68,7 +52,7 @@ def assert_valid(data: Mapping, schema_id: str) -> None: >>> assert_valid( ... {'v': 27, 'r': '0x'+'f'*64, 's': '0x'+'f'*64}, - ... '/ECSignature', + ... '/ecSignatureSchema', ... ) """ # noqa |