aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/json-schemas/README.md19
-rw-r--r--packages/website/md/docs/json_schemas/usage.md14
-rw-r--r--packages/website/ts/containers/json_schemas_documentation.ts4
3 files changed, 27 insertions, 10 deletions
diff --git a/packages/json-schemas/README.md b/packages/json-schemas/README.md
index 754ce4e95..961c3746d 100644
--- a/packages/json-schemas/README.md
+++ b/packages/json-schemas/README.md
@@ -2,25 +2,24 @@
Contains 0x-related json schemas
+### Read the [Documentation](0xproject.com/docs/json-schemas).
+
## Installation
```bash
-yarn add @0xproject/json-schemas
+npm install @0xproject/json-schemas --save
```
-## Usage
+**Import**
```javascript
-import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';
+import { schemas } from '@0xproject/json-schemas';
+```
-const {orderSchema} = schemas;
-const validator = new SchemaValidator();
+or
-const order = {
- ...
-};
-const validatorResult: ValidatorResult = validator.validate(order, orderSchema); // Contains all errors
-const isValid: boolean = validator.isValid(order, orderSchema); // Only returns boolean
+```javascript
+var schemas = require('@0xproject/json-schemas').schemas;
```
## Contributing
diff --git a/packages/website/md/docs/json_schemas/usage.md b/packages/website/md/docs/json_schemas/usage.md
new file mode 100644
index 000000000..372c0b541
--- /dev/null
+++ b/packages/website/md/docs/json_schemas/usage.md
@@ -0,0 +1,14 @@
+The following example shows you how to validate an 0x order using the `@0xproject/json-schemas` package.
+
+```javascript
+import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';
+
+const {orderSchema} = schemas;
+const validator = new SchemaValidator();
+
+const order = {
+ ...
+};
+const validatorResult: ValidatorResult = validator.validate(order, orderSchema); // Contains all errors
+const isValid: boolean = validator.isValid(order, orderSchema); // Only returns boolean
+```
diff --git a/packages/website/ts/containers/json_schemas_documentation.ts b/packages/website/ts/containers/json_schemas_documentation.ts
index 42e441212..154c65ffc 100644
--- a/packages/website/ts/containers/json_schemas_documentation.ts
+++ b/packages/website/ts/containers/json_schemas_documentation.ts
@@ -14,12 +14,14 @@ import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
const IntroMarkdown = require('md/docs/json_schemas/introduction');
const InstallationMarkdown = require('md/docs/json_schemas/installation');
+const UsageMarkdown = require('md/docs/json_schemas/usage');
const SchemasMarkdown = require('md/docs/json_schemas/schemas');
/* tslint:enable:no-var-requires */
const docSections = {
introduction: 'introduction',
installation: 'installation',
+ usage: 'usage',
schemaValidator: 'schemaValidator',
schemas: 'schemas',
};
@@ -32,6 +34,7 @@ const docsInfoConfig: DocsInfoConfig = {
menu: {
introduction: [docSections.introduction],
install: [docSections.installation],
+ usage: [docSections.usage],
schemaValidator: [docSections.schemaValidator],
schemas: [docSections.schemas],
},
@@ -39,6 +42,7 @@ const docsInfoConfig: DocsInfoConfig = {
[docSections.introduction]: IntroMarkdown,
[docSections.installation]: InstallationMarkdown,
[docSections.schemas]: SchemasMarkdown,
+ [docSections.usage]: UsageMarkdown,
},
sectionNameToModulePath: {
[docSections.schemaValidator]: ['"json-schemas/src/schema_validator"'],