aboutsummaryrefslogtreecommitdiffstats
path: root/packages/json-schemas/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/json-schemas/src')
-rw-r--r--packages/json-schemas/src/index.ts4
-rw-r--r--packages/json-schemas/src/schema_validator.ts61
-rw-r--r--packages/json-schemas/src/schemas.ts95
3 files changed, 0 insertions, 160 deletions
diff --git a/packages/json-schemas/src/index.ts b/packages/json-schemas/src/index.ts
deleted file mode 100644
index 9d8470348..000000000
--- a/packages/json-schemas/src/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export { ValidatorResult, Schema } from 'jsonschema';
-
-export { SchemaValidator } from './schema_validator';
-export { schemas } from './schemas';
diff --git a/packages/json-schemas/src/schema_validator.ts b/packages/json-schemas/src/schema_validator.ts
deleted file mode 100644
index 43647b594..000000000
--- a/packages/json-schemas/src/schema_validator.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { Schema, Validator, ValidatorResult } from 'jsonschema';
-import values = require('lodash.values');
-
-import { schemas } from './schemas';
-
-/**
- * A validator for [JSON-schemas](http://json-schema.org/)
- */
-export class SchemaValidator {
- private readonly _validator: Validator;
- private static _assertSchemaDefined(schema: Schema): void {
- if (schema === undefined) {
- throw new Error(`Cannot add undefined schema`);
- }
- }
- /**
- * Instantiates a SchemaValidator instance
- */
- constructor() {
- this._validator = new Validator();
- for (const schema of values(schemas)) {
- SchemaValidator._assertSchemaDefined(schema);
- this._validator.addSchema(schema, schema.id);
- }
- }
- /**
- * Add a schema to the validator. All schemas and sub-schemas must be added to
- * the validator before the `validate` and `isValid` methods can be called with
- * instances of that schema.
- * @param schema The schema to add
- */
- public addSchema(schema: Schema): void {
- SchemaValidator._assertSchemaDefined(schema);
- this._validator.addSchema(schema, schema.id);
- }
- // In order to validate a complex JS object using jsonschema, we must replace any complex
- // sub-types (e.g BigNumber) with a simpler string representation. Since BigNumber and other
- // complex types implement the `toString` method, we can stringify the object and
- // then parse it. The resultant object can then be checked using jsonschema.
- /**
- * Validate the JS object conforms to a specific JSON schema
- * @param instance JS object in question
- * @param schema Schema to check against
- * @returns The results of the validation
- */
- public validate(instance: any, schema: Schema): ValidatorResult {
- SchemaValidator._assertSchemaDefined(schema);
- const jsonSchemaCompatibleObject = JSON.parse(JSON.stringify(instance));
- return this._validator.validate(jsonSchemaCompatibleObject, schema);
- }
- /**
- * Check whether an instance properly adheres to a JSON schema
- * @param instance JS object in question
- * @param schema Schema to check against
- * @returns Whether or not the instance adheres to the schema
- */
- public isValid(instance: any, schema: Schema): boolean {
- const isValid = this.validate(instance, schema).errors.length === 0;
- return isValid;
- }
-}
diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts
deleted file mode 100644
index 9e8eb6959..000000000
--- a/packages/json-schemas/src/schemas.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import * as addressSchema from '../schemas/address_schema.json';
-import * as assetPairsRequestOptsSchema from '../schemas/asset_pairs_request_opts_schema.json';
-import * as blockParamSchema from '../schemas/block_param_schema.json';
-import * as blockRangeSchema from '../schemas/block_range_schema.json';
-import * as callDataSchema from '../schemas/call_data_schema.json';
-import * as ecSignatureParameterSchema from '../schemas/ec_signature_parameter_schema.json';
-import * as ecSignatureSchema from '../schemas/ec_signature_schema.json';
-import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json';
-import * as hexSchema from '../schemas/hex_schema.json';
-import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json';
-import * as jsNumber from '../schemas/js_number_schema.json';
-import * as numberSchema from '../schemas/number_schema.json';
-import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json';
-import * as orderConfigRequestSchema from '../schemas/order_config_request_schema.json';
-import * as orderFillOrKillRequestsSchema from '../schemas/order_fill_or_kill_requests_schema.json';
-import * as orderFillRequestsSchema from '../schemas/order_fill_requests_schema.json';
-import * as orderHashSchema from '../schemas/order_hash_schema.json';
-import * as orderSchema from '../schemas/order_schema.json';
-import * as orderWatcherWebSocketRequestSchema from '../schemas/order_watcher_web_socket_request_schema.json';
-import * as orderWatcherWebSocketUtf8MessageSchema from '../schemas/order_watcher_web_socket_utf8_message_schema.json';
-import * as orderBookRequestSchema from '../schemas/orderbook_request_schema.json';
-import * as ordersRequestOptsSchema from '../schemas/orders_request_opts_schema.json';
-import * as ordersSchema from '../schemas/orders_schema.json';
-import * as pagedRequestOptsSchema from '../schemas/paged_request_opts_schema.json';
-import * as paginatedCollectionSchema from '../schemas/paginated_collection_schema.json';
-import * as relayerApiAssetDataPairsResponseSchema from '../schemas/relayer_api_asset_data_pairs_response_schema.json';
-import * as relayerApiAssetDataPairsSchema from '../schemas/relayer_api_asset_data_pairs_schema.json';
-import * as relayerApiAssetDataTradeInfoSchema from '../schemas/relayer_api_asset_data_trade_info_schema.json';
-import * as relayerApiErrorResponseSchema from '../schemas/relayer_api_error_response_schema.json';
-import * as relayerApiFeeRecipientsResponseSchema from '../schemas/relayer_api_fee_recipients_response_schema.json';
-import * as relayerApiOrderConfigPayloadSchema from '../schemas/relayer_api_order_config_payload_schema.json';
-import * as relayerApiOrderConfigResponseSchema from '../schemas/relayer_api_order_config_response_schema.json';
-import * as relayerApiOrderSchema from '../schemas/relayer_api_order_schema.json';
-import * as relayerApiOrderbookResponseSchema from '../schemas/relayer_api_orderbook_response_schema.json';
-import * as relayerApiOrdersChannelSubscribePayloadSchema from '../schemas/relayer_api_orders_channel_subscribe_payload_schema.json';
-import * as relayerApiOrdersChannelSubscribeSchema from '../schemas/relayer_api_orders_channel_subscribe_schema.json';
-import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json';
-import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json';
-import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json';
-import * as requestOptsSchema from '../schemas/request_opts_schema.json';
-import * as signedOrderSchema from '../schemas/signed_order_schema.json';
-import * as signedOrdersSchema from '../schemas/signed_orders_schema.json';
-import * as tokenSchema from '../schemas/token_schema.json';
-import * as txDataSchema from '../schemas/tx_data_schema.json';
-import * as wholeNumberSchema from '../schemas/whole_number_schema.json';
-import * as zeroExTransactionSchema from '../schemas/zero_ex_transaction_schema.json';
-
-export const schemas = {
- numberSchema,
- addressSchema,
- callDataSchema,
- hexSchema,
- ecSignatureParameterSchema,
- ecSignatureSchema,
- eip712TypedDataSchema,
- indexFilterValuesSchema,
- orderCancellationRequestsSchema,
- orderFillOrKillRequestsSchema,
- orderFillRequestsSchema,
- orderHashSchema,
- orderSchema,
- signedOrderSchema,
- signedOrdersSchema,
- ordersSchema,
- blockParamSchema,
- blockRangeSchema,
- tokenSchema,
- jsNumber,
- requestOptsSchema,
- pagedRequestOptsSchema,
- orderWatcherWebSocketRequestSchema,
- orderWatcherWebSocketUtf8MessageSchema,
- ordersRequestOptsSchema,
- orderBookRequestSchema,
- orderConfigRequestSchema,
- assetPairsRequestOptsSchema,
- txDataSchema,
- paginatedCollectionSchema,
- relayerApiErrorResponseSchema,
- relayerApiFeeRecipientsResponseSchema,
- relayerApiOrderSchema,
- relayerApiOrdersSchema,
- relayerApiOrderConfigPayloadSchema,
- relayerApiOrderConfigResponseSchema,
- relayerApiOrderbookResponseSchema,
- relayerApiAssetDataPairsResponseSchema,
- relayerApiAssetDataTradeInfoSchema,
- relayerApiOrdersChannelSubscribeSchema,
- relayerApiOrdersChannelSubscribePayloadSchema,
- relayerApiOrdersChannelUpdateSchema,
- relayerApiOrdersResponseSchema,
- relayerApiAssetDataPairsSchema,
- zeroExTransactionSchema,
- wholeNumberSchema,
-};