Correct inconsistencies in JSON schema names

In both ref ID's and file names.
This commit is contained in:
F. Eugene Aumson
2018-12-28 15:08:15 -05:00
parent 7e12ae1bfc
commit a3eab71908
14 changed files with 23 additions and 36 deletions

View File

@@ -27,3 +27,6 @@ lib
package.json package.json
scripts/postpublish_utils.js scripts/postpublish_utils.js
packages/sol-cov/test/fixtures/artifacts packages/sol-cov/test/fixtures/artifacts
.pytest_cache
.mypy_cache
.tox

View File

@@ -1,5 +1,5 @@
{ {
"id": "/AssetPairsRequestOpts", "id": "/AssetPairsRequestOptsSchema",
"type": "object", "type": "object",
"properties": { "properties": {
"assetDataA": { "$ref": "/hexSchema" }, "assetDataA": { "$ref": "/hexSchema" },

View File

@@ -4,13 +4,13 @@
"from": { "$ref": "/addressSchema" }, "from": { "$ref": "/addressSchema" },
"to": { "$ref": "/addressSchema" }, "to": { "$ref": "/addressSchema" },
"value": { "value": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
}, },
"gas": { "gas": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
}, },
"gasPrice": { "gasPrice": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
}, },
"data": { "data": {
"type": "string", "type": "string",

View File

@@ -1,5 +1,5 @@
{ {
"id": "/ECSignature", "id": "/ecSignatureSchema",
"properties": { "properties": {
"v": { "v": {
"type": "number", "type": "number",

View File

@@ -1,5 +1,5 @@
{ {
"id": "/jsNumber", "id": "/jsNumberSchema",
"type": "number", "type": "number",
"minimum": 0 "minimum": 0
} }

View File

@@ -1,5 +1,5 @@
{ {
"id": "/OrderConfigRequest", "id": "/OrderConfigRequestSchema",
"type": "object", "type": "object",
"properties": { "properties": {
"makerAddress": { "$ref": "/addressSchema" }, "makerAddress": { "$ref": "/addressSchema" },

View File

@@ -1,9 +1,9 @@
{ {
"id": "/OrderBookRequest", "id": "/OrderbookRequestSchema",
"type": "object", "type": "object",
"properties": { "properties": {
"baseAssetData": { "$ref": "/hexSchema" }, "baseAssetData": { "$ref": "/hexSchema" },
"quoteAssetData": { "$ref": "/hexSchema" } "quoteAssetData": { "$ref": "/hexSchema" }
}, },
"required": ["baseAssetData", "quoteAssetData"] "required": ["baseAssetData", "quoteAssetData"]
} }

View File

@@ -1,5 +1,5 @@
{ {
"id": "/OrdersRequestOpts", "id": "/OrdersRequestOptsSchema",
"type": "object", "type": "object",
"properties": { "properties": {
"makerAssetProxyId": { "$ref": "/hexSchema" }, "makerAssetProxyId": { "$ref": "/hexSchema" },

View File

@@ -1,5 +1,5 @@
{ {
"id": "/PagedRequestOpts", "id": "/PagedRequestOptsSchema",
"type": "object", "type": "object",
"properties": { "properties": {
"page": { "type": "number" }, "page": { "type": "number" },

View File

@@ -1,5 +1,5 @@
{ {
"id": "/RequestOpts", "id": "/RequestOptsSchema",
"type": "object", "type": "object",
"properties": { "properties": {
"networkId": { "type": "number" } "networkId": { "type": "number" }

View File

@@ -4,13 +4,13 @@
"from": { "$ref": "/addressSchema" }, "from": { "$ref": "/addressSchema" },
"to": { "$ref": "/addressSchema" }, "to": { "$ref": "/addressSchema" },
"value": { "value": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
}, },
"gas": { "gas": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
}, },
"gasPrice": { "gasPrice": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
}, },
"data": { "data": {
"type": "string", "type": "string",

View File

@@ -8,7 +8,7 @@ import * as ecSignatureSchema from '../schemas/ec_signature_schema.json';
import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json'; import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json';
import * as hexSchema from '../schemas/hex_schema.json'; import * as hexSchema from '../schemas/hex_schema.json';
import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json'; import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json';
import * as jsNumber from '../schemas/js_number.json'; import * as jsNumber from '../schemas/js_number_schema.json';
import * as numberSchema from '../schemas/number_schema.json'; import * as numberSchema from '../schemas/number_schema.json';
import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json'; import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json';
import * as orderConfigRequestSchema from '../schemas/order_config_request_schema.json'; import * as orderConfigRequestSchema from '../schemas/order_config_request_schema.json';

View File

@@ -40,7 +40,7 @@
"./schemas/relayer_api_orders_schema.json", "./schemas/relayer_api_orders_schema.json",
"./schemas/signed_orders_schema.json", "./schemas/signed_orders_schema.json",
"./schemas/token_schema.json", "./schemas/token_schema.json",
"./schemas/js_number.json", "./schemas/js_number_schema.json",
"./schemas/zero_ex_transaction_schema.json", "./schemas/zero_ex_transaction_schema.json",
"./schemas/tx_data_schema.json", "./schemas/tx_data_schema.json",
"./schemas/index_filter_values_schema.json", "./schemas/index_filter_values_schema.json",

View File

@@ -17,23 +17,7 @@ class _LocalRefResolver(jsonschema.RefResolver):
jsonschema.RefResolver.__init__(self, "", "") jsonschema.RefResolver.__init__(self, "", "")
@staticmethod @staticmethod
def _ref_to_file(ref: str) -> str: def resolve_from_url(url: 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:
"""Resolve the given URL. """Resolve the given URL.
:param url: a string representing the URL of the JSON schema to fetch. :param url: a string representing the URL of the JSON schema to fetch.
@@ -45,7 +29,7 @@ class _LocalRefResolver(jsonschema.RefResolver):
return json.loads( return json.loads(
resource_string( resource_string(
"zero_ex.json_schemas", "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( >>> assert_valid(
... {'v': 27, 'r': '0x'+'f'*64, 's': '0x'+'f'*64}, ... {'v': 27, 'r': '0x'+'f'*64, 's': '0x'+'f'*64},
... '/ECSignature', ... '/ecSignatureSchema',
... ) ... )
""" """
# noqa # noqa