Add JSON Schemas docs to website
This commit is contained in:
17
packages/website/md/docs/json_schemas/installation.md
Normal file
17
packages/website/md/docs/json_schemas/installation.md
Normal file
@@ -0,0 +1,17 @@
|
||||
**Install**
|
||||
|
||||
```bash
|
||||
npm install @0xproject/json-schemas --save
|
||||
```
|
||||
|
||||
**Import**
|
||||
|
||||
```javascript
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```javascript
|
||||
var schemas = require('@0xproject/json-schemas').schemas;
|
||||
```
|
||||
3
packages/website/md/docs/json_schemas/introduction.md
Normal file
3
packages/website/md/docs/json_schemas/introduction.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Welcome to the [@0xproject/json-schemas](https://github.com/0xProject/0x-monorepo/tree/development/packages/json-schemas) documentation! This package provides JSON schemas for validating 0x Protocol & Standard Relayer API data structures. It provides both the raw JSON schemas and a schema validator class to interact with them from a JS project.
|
||||
|
||||
If you are not using a Javascript-based language for your project, you can copy-paste the JSON schemas within this package and use them together with a [JSON Schema](http://json-schema.org/) implementation in your [language of choice](http://json-schema.org/implementations.html) (e.g Python, Haskell, Go, C, C++, Rust, Ruby, Scala, etc...).
|
||||
28
packages/website/md/docs/json_schemas/schemas.md
Normal file
28
packages/website/md/docs/json_schemas/schemas.md
Normal file
@@ -0,0 +1,28 @@
|
||||
0x Protocol Schemas
|
||||
|
||||
* [Basic types](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/basic_type_schemas.ts) (e.g Ethereum address, number)
|
||||
* [ECSignature](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/ec_signature_schema.ts)
|
||||
* [Order/SignedOrder](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_schemas.ts)
|
||||
* [OrderHash](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_hash_schema.ts)
|
||||
|
||||
0x.js Schemas
|
||||
|
||||
* [BlockRange](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/block_range_schema.ts)
|
||||
* [IndexFilter Values](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/index_filter_values_schema.ts)
|
||||
* [OrderFillRequests](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_fill_requests_schema.ts)
|
||||
* [OrderCancellationRequests](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_cancel_schema.ts)
|
||||
* [OrderFillOrKillRequests](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts)
|
||||
* [SignedOrders](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/signed_orders_schema.ts)
|
||||
* [Token](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/token_schema.ts)
|
||||
* [TxData](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/tx_data_schema.ts)
|
||||
|
||||
Standard Relayer API Schemas
|
||||
|
||||
* [Error response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_error_response_schema.ts)
|
||||
* [Fees payload](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts)
|
||||
* [Fees response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts)
|
||||
* [Orderbook channel subscribe](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts)
|
||||
* [Orderbook channel snapshot](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts)
|
||||
* [Orderbook channel update](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts)
|
||||
* [Orderbook response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts)
|
||||
* [Token pairs response](https://github.com/0xProject/0x-monorepo/blob/d4c1b3b0bd26e730ce6687469cdf7283877543e1/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts)
|
||||
@@ -57,6 +57,7 @@
|
||||
"CAREERS": "人才招聘",
|
||||
"CONTACT": "联系方式",
|
||||
"DEPLOYER": "Deployer",
|
||||
"JSON_SCHEMAS": "JSON Schemas",
|
||||
"BLOG": "博客",
|
||||
"FORUM": "论坛",
|
||||
"CONNECT": "0x 连接",
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
"CAREERS": "careers",
|
||||
"CONTACT": "contact",
|
||||
"DEPLOYER": "Deployer",
|
||||
"JSON_SCHEMAS": "JSON Schemas",
|
||||
"BLOG": "blog",
|
||||
"FORUM": "forum",
|
||||
"CONNECT": "0x Connect",
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
"CAREERS": "채용",
|
||||
"CONTACT": "문의",
|
||||
"DEPLOYER": "Deployer",
|
||||
"JSON_SCHEMAS": "JSON Schemas",
|
||||
"BLOG": "블로그",
|
||||
"FORUM": "포럼",
|
||||
"CONNECT": "0x Connect",
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
"CAREERS": "Карьера",
|
||||
"CONTACT": "Связаться с нами",
|
||||
"DEPLOYER": "Deployer",
|
||||
"JSON_SCHEMAS": "JSON Schemas",
|
||||
"BLOG": "Блог",
|
||||
"FORUM": "Форум",
|
||||
"CONNECT": "0x Connect",
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
"CAREERS": "empleo",
|
||||
"CONTACT": "contacto",
|
||||
"DEPLOYER": "Deployer",
|
||||
"JSON_SCHEMAS": "JSON Schemas",
|
||||
"BLOG": "blog",
|
||||
"FORUM": "foro",
|
||||
"CONNECT": "0x Connect",
|
||||
|
||||
@@ -8,6 +8,7 @@ const titleToIcon: { [title: string]: string } = {
|
||||
'0x.js': 'zeroExJs.png',
|
||||
Web3Wrapper: 'zeroExJs.png',
|
||||
Deployer: 'zeroExJs.png',
|
||||
'JSON Schemas': 'zeroExJs.png',
|
||||
'0x Connect': 'connect.png',
|
||||
'0x Smart Contracts': 'contracts.png',
|
||||
Wiki: 'wiki.png',
|
||||
|
||||
@@ -151,6 +151,12 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
primaryText={this.props.translate.get(Key.Deployer, Deco.CapWords)}
|
||||
/>
|
||||
</Link>,
|
||||
<Link key="subMenuItem-jsonSchema" to={WebsitePaths.JSONSchemas} className="text-decoration-none">
|
||||
<MenuItem
|
||||
style={{ fontSize: styles.menuItem.fontSize }}
|
||||
primaryText={this.props.translate.get(Key.JsonSchemas, Deco.CapWords)}
|
||||
/>
|
||||
</Link>,
|
||||
];
|
||||
const bottomBorderStyle = this._shouldDisplayBottomBar() ? styles.bottomBar : {};
|
||||
const fullWidthClasses = isFullWidthPage ? 'pr4' : '';
|
||||
@@ -305,6 +311,14 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
</MenuItem>
|
||||
</Link>
|
||||
)}
|
||||
{!this._isViewingJsonSchemasDocs() && (
|
||||
<Link to={WebsitePaths.JSONSchemas} className="text-decoration-none">
|
||||
<MenuItem className="py2">
|
||||
{this.props.translate.get(Key.JsonSchemas, Deco.Cap)}{' '}
|
||||
{this.props.translate.get(Key.Docs, Deco.Cap)}
|
||||
</MenuItem>
|
||||
</Link>
|
||||
)}
|
||||
{!this._isViewingPortal() && (
|
||||
<Link to={`${WebsitePaths.Portal}`} className="text-decoration-none">
|
||||
<MenuItem className="py2">
|
||||
@@ -336,6 +350,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
!this._isViewingSmartContractsDocs() &&
|
||||
!this._isViewingWeb3WrapperDocs() &&
|
||||
!this._isViewingDeployerDocs() &&
|
||||
!this._isViewingJsonSchemasDocs() &&
|
||||
!this._isViewingConnectDocs()) ||
|
||||
_.isUndefined(this.props.menu)
|
||||
) {
|
||||
@@ -430,6 +445,9 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
private _isViewingDeployerDocs() {
|
||||
return _.includes(this.props.location.pathname, WebsitePaths.Deployer);
|
||||
}
|
||||
private _isViewingJsonSchemasDocs() {
|
||||
return _.includes(this.props.location.pathname, WebsitePaths.JSONSchemas);
|
||||
}
|
||||
private _isViewingWiki() {
|
||||
return _.includes(this.props.location.pathname, WebsitePaths.Wiki);
|
||||
}
|
||||
@@ -441,6 +459,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
this._isViewingSmartContractsDocs() ||
|
||||
this._isViewingWeb3WrapperDocs() ||
|
||||
this._isViewingDeployerDocs() ||
|
||||
this._isViewingJsonSchemasDocs() ||
|
||||
this._isViewingConnectDocs()
|
||||
);
|
||||
}
|
||||
|
||||
85
packages/website/ts/containers/json_schemas_documentation.ts
Normal file
85
packages/website/ts/containers/json_schemas_documentation.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { constants as docConstants, DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs';
|
||||
import * as _ from 'lodash';
|
||||
import * as React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { Dispatch } from 'redux';
|
||||
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
|
||||
import { Dispatcher } from 'ts/redux/dispatcher';
|
||||
import { State } from 'ts/redux/reducer';
|
||||
import { DocPackages, Environments, WebsitePaths } from 'ts/types';
|
||||
import { configs } from 'ts/utils/configs';
|
||||
import { constants } from 'ts/utils/constants';
|
||||
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 SchemasMarkdown = require('md/docs/json_schemas/schemas');
|
||||
/* tslint:enable:no-var-requires */
|
||||
|
||||
const docSections = {
|
||||
introduction: 'introduction',
|
||||
installation: 'installation',
|
||||
schemaValidator: 'schemaValidator',
|
||||
schemas: 'schemas',
|
||||
};
|
||||
|
||||
const docsInfoConfig: DocsInfoConfig = {
|
||||
id: DocPackages.JSONSchemas,
|
||||
type: SupportedDocJson.TypeDoc,
|
||||
displayName: 'JSON Schemas',
|
||||
packageUrl: 'https://github.com/0xProject/0x-monorepo',
|
||||
menu: {
|
||||
introduction: [docSections.introduction],
|
||||
install: [docSections.installation],
|
||||
schemaValidator: [docSections.schemaValidator],
|
||||
schemas: [docSections.schemas],
|
||||
},
|
||||
sectionNameToMarkdown: {
|
||||
[docSections.introduction]: IntroMarkdown,
|
||||
[docSections.installation]: InstallationMarkdown,
|
||||
[docSections.schemas]: SchemasMarkdown,
|
||||
},
|
||||
sectionNameToModulePath: {
|
||||
[docSections.schemaValidator]: ['"json-schemas/src/schema_validator"'],
|
||||
},
|
||||
menuSubsectionToVersionWhenIntroduced: {},
|
||||
sections: docSections,
|
||||
visibleConstructors: [docSections.schemaValidator],
|
||||
typeConfigs: {
|
||||
// Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
|
||||
// currently no way to extract the re-exported types from index.ts via TypeDoc :(
|
||||
publicTypes: [],
|
||||
typeNameToExternalLink: {
|
||||
Schema:
|
||||
'https://github.com/tdegrunt/jsonschema/blob/5c2edd4baba149964aec0f23c87ad12c25a50dfb/lib/index.d.ts#L49',
|
||||
},
|
||||
},
|
||||
};
|
||||
const docsInfo = new DocsInfo(docsInfoConfig);
|
||||
|
||||
interface ConnectedState {
|
||||
docsVersion: string;
|
||||
availableDocVersions: string[];
|
||||
docsInfo: DocsInfo;
|
||||
translate: Translate;
|
||||
}
|
||||
|
||||
interface ConnectedDispatch {
|
||||
dispatcher: Dispatcher;
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: State, ownProps: DocPageProps): ConnectedState => ({
|
||||
docsVersion: state.docsVersion,
|
||||
availableDocVersions: state.availableDocVersions,
|
||||
translate: state.translate,
|
||||
docsInfo,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
|
||||
dispatcher: new Dispatcher(dispatch),
|
||||
});
|
||||
|
||||
export const Documentation: React.ComponentClass<DocPageProps> = connect(mapStateToProps, mapDispatchToProps)(
|
||||
DocPageComponent,
|
||||
);
|
||||
@@ -51,6 +51,9 @@ const LazyWeb3WrapperDocumentation = createLazyComponent('Documentation', async
|
||||
const LazyDeployerDocumentation = createLazyComponent('Documentation', async () =>
|
||||
System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/deployer_documentation'),
|
||||
);
|
||||
const LazyJSONSchemasDocumentation = createLazyComponent('Documentation', async () =>
|
||||
System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/json_schemas_documentation'),
|
||||
);
|
||||
|
||||
analytics.init();
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
@@ -72,6 +75,10 @@ render(
|
||||
<Route path={`${WebsitePaths.ZeroExJs}/:version?`} component={LazyZeroExJSDocumentation} />
|
||||
<Route path={`${WebsitePaths.Connect}/:version?`} component={LazyConnectDocumentation} />
|
||||
<Route path={`${WebsitePaths.Deployer}/:version?`} component={LazyDeployerDocumentation} />
|
||||
<Route
|
||||
path={`${WebsitePaths.JSONSchemas}/:version?`}
|
||||
component={LazyJSONSchemasDocumentation}
|
||||
/>
|
||||
<Route
|
||||
path={`${WebsitePaths.Web3Wrapper}/:version?`}
|
||||
component={LazyWeb3WrapperDocumentation}
|
||||
|
||||
@@ -17,13 +17,14 @@ import { utils } from 'ts/utils/utils';
|
||||
|
||||
const ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH = '0.32.4';
|
||||
|
||||
const isDevelopment = configs.ENVIRONMENT !== Environments.DEVELOPMENT;
|
||||
const isDevelopment = configs.ENVIRONMENT === Environments.DEVELOPMENT;
|
||||
const docIdToS3FolderName: { [id: string]: string } = {
|
||||
[DocPackages.ZeroExJs]: '0xjs',
|
||||
[DocPackages.SmartContracts]: 'smart-contracts',
|
||||
[DocPackages.Connect]: 'connect',
|
||||
[DocPackages.Web3Wrapper]: 'web3-wrapper',
|
||||
[DocPackages.Deployer]: 'deployer',
|
||||
[DocPackages.JSONSchemas]: 'json-schemas',
|
||||
};
|
||||
|
||||
const docIdToSubpackageName: { [id: string]: string } = {
|
||||
@@ -32,6 +33,7 @@ const docIdToSubpackageName: { [id: string]: string } = {
|
||||
[DocPackages.SmartContracts]: 'contracts',
|
||||
[DocPackages.Web3Wrapper]: 'web3-wrapper',
|
||||
[DocPackages.Deployer]: 'deployer',
|
||||
[DocPackages.JSONSchemas]: 'json-schemas',
|
||||
};
|
||||
|
||||
export interface DocPageProps {
|
||||
|
||||
@@ -357,6 +357,7 @@ export enum WebsitePaths {
|
||||
Connect = '/docs/connect',
|
||||
Web3Wrapper = '/docs/web3_wrapper',
|
||||
Deployer = '/docs/deployer',
|
||||
JSONSchemas = '/docs/json-schemas',
|
||||
}
|
||||
|
||||
export enum DocPackages {
|
||||
@@ -365,6 +366,7 @@ export enum DocPackages {
|
||||
SmartContracts = 'SMART_CONTRACTS',
|
||||
Web3Wrapper = 'WEB3_WRAPPER',
|
||||
Deployer = 'DEPLOYER',
|
||||
JSONSchemas = 'JSON_SCHEMAS',
|
||||
}
|
||||
|
||||
export interface TimestampMsRange {
|
||||
@@ -447,6 +449,7 @@ export enum Key {
|
||||
Careers = 'CAREERS',
|
||||
Contact = 'CONTACT',
|
||||
Deployer = 'DEPLOYER',
|
||||
JsonSchemas = 'JSON_SCHEMAS',
|
||||
Blog = 'BLOG',
|
||||
Forum = 'FORUM',
|
||||
Connect = 'CONNECT',
|
||||
|
||||
Reference in New Issue
Block a user