Move docs to page and add link to docs to README
This commit is contained in:
@@ -2,25 +2,24 @@
|
|||||||
|
|
||||||
Contains 0x-related json schemas
|
Contains 0x-related json schemas
|
||||||
|
|
||||||
|
### Read the [Documentation](0xproject.com/docs/json-schemas).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @0xproject/json-schemas
|
npm install @0xproject/json-schemas --save
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
**Import**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
|
```
|
||||||
|
|
||||||
const {orderSchema} = schemas;
|
or
|
||||||
const validator = new SchemaValidator();
|
|
||||||
|
|
||||||
const order = {
|
```javascript
|
||||||
...
|
var schemas = require('@0xproject/json-schemas').schemas;
|
||||||
};
|
|
||||||
const validatorResult: ValidatorResult = validator.validate(order, orderSchema); // Contains all errors
|
|
||||||
const isValid: boolean = validator.isValid(order, orderSchema); // Only returns boolean
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
14
packages/website/md/docs/json_schemas/usage.md
Normal file
14
packages/website/md/docs/json_schemas/usage.md
Normal file
@@ -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
|
||||||
|
```
|
@@ -14,12 +14,14 @@ import { Translate } from 'ts/utils/translate';
|
|||||||
/* tslint:disable:no-var-requires */
|
/* tslint:disable:no-var-requires */
|
||||||
const IntroMarkdown = require('md/docs/json_schemas/introduction');
|
const IntroMarkdown = require('md/docs/json_schemas/introduction');
|
||||||
const InstallationMarkdown = require('md/docs/json_schemas/installation');
|
const InstallationMarkdown = require('md/docs/json_schemas/installation');
|
||||||
|
const UsageMarkdown = require('md/docs/json_schemas/usage');
|
||||||
const SchemasMarkdown = require('md/docs/json_schemas/schemas');
|
const SchemasMarkdown = require('md/docs/json_schemas/schemas');
|
||||||
/* tslint:enable:no-var-requires */
|
/* tslint:enable:no-var-requires */
|
||||||
|
|
||||||
const docSections = {
|
const docSections = {
|
||||||
introduction: 'introduction',
|
introduction: 'introduction',
|
||||||
installation: 'installation',
|
installation: 'installation',
|
||||||
|
usage: 'usage',
|
||||||
schemaValidator: 'schemaValidator',
|
schemaValidator: 'schemaValidator',
|
||||||
schemas: 'schemas',
|
schemas: 'schemas',
|
||||||
};
|
};
|
||||||
@@ -32,6 +34,7 @@ const docsInfoConfig: DocsInfoConfig = {
|
|||||||
menu: {
|
menu: {
|
||||||
introduction: [docSections.introduction],
|
introduction: [docSections.introduction],
|
||||||
install: [docSections.installation],
|
install: [docSections.installation],
|
||||||
|
usage: [docSections.usage],
|
||||||
schemaValidator: [docSections.schemaValidator],
|
schemaValidator: [docSections.schemaValidator],
|
||||||
schemas: [docSections.schemas],
|
schemas: [docSections.schemas],
|
||||||
},
|
},
|
||||||
@@ -39,6 +42,7 @@ const docsInfoConfig: DocsInfoConfig = {
|
|||||||
[docSections.introduction]: IntroMarkdown,
|
[docSections.introduction]: IntroMarkdown,
|
||||||
[docSections.installation]: InstallationMarkdown,
|
[docSections.installation]: InstallationMarkdown,
|
||||||
[docSections.schemas]: SchemasMarkdown,
|
[docSections.schemas]: SchemasMarkdown,
|
||||||
|
[docSections.usage]: UsageMarkdown,
|
||||||
},
|
},
|
||||||
sectionNameToModulePath: {
|
sectionNameToModulePath: {
|
||||||
[docSections.schemaValidator]: ['"json-schemas/src/schema_validator"'],
|
[docSections.schemaValidator]: ['"json-schemas/src/schema_validator"'],
|
||||||
|
Reference in New Issue
Block a user