From a3eab71908cd2e188438b4d411b7c426c874f0b2 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Fri, 28 Dec 2018 15:08:15 -0500 Subject: Correct inconsistencies in JSON schema names In both ref ID's and file names. --- .../src/zero_ex/json_schemas/__init__.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'python-packages') 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 -- cgit v1.2.3