aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-api/src
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-11 06:56:47 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-11 06:56:47 +0800
commitb6d793aec4dbb8edad8c8c28e6a2200912b46cf3 (patch)
tree264051dc4e61253a7f1645d1734414fad8034e09 /packages/sra-api/src
parent083319786fad31dfde16cb9e06e893bfeb23785d (diff)
downloaddexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.tar
dexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.tar.gz
dexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.tar.bz2
dexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.tar.lz
dexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.tar.xz
dexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.tar.zst
dexon-sol-tools-b6d793aec4dbb8edad8c8c28e6a2200912b46cf3.zip
Enforce camelCase for all parameters and change the way the site is deployed and hosted
Diffstat (limited to 'packages/sra-api/src')
-rw-r--r--packages/sra-api/src/api.ts8
-rw-r--r--packages/sra-api/src/md/introduction.md38
-rw-r--r--packages/sra-api/src/parameters.ts4
3 files changed, 25 insertions, 25 deletions
diff --git a/packages/sra-api/src/api.ts b/packages/sra-api/src/api.ts
index c2236fda5..4143a663c 100644
--- a/packages/sra-api/src/api.ts
+++ b/packages/sra-api/src/api.ts
@@ -21,12 +21,12 @@ export const api: OpenApiSpec = {
'/v2/asset_pairs': {
get: {
description:
- 'Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `asset_data_a` or `asset_data_b` returns pairs filtered by that asset only.',
+ 'Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `assetDataA` or `assetDataB` returns pairs filtered by that asset only.',
operationId: 'getAssetPairs',
parameters: generateParameters(
[
{
- name: 'asset_data_a',
+ name: 'assetDataA',
in: 'query',
description: 'The assetData value for the first asset in the pair.',
example: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
@@ -35,7 +35,7 @@ export const api: OpenApiSpec = {
},
},
{
- name: 'asset_data_b',
+ name: 'assetDataB',
in: 'query',
description: 'The assetData value for the second asset in the pair.',
example: '0x0257179264389b814a946f3e92105513705ca6b990',
@@ -205,7 +205,7 @@ export const api: OpenApiSpec = {
},
'/v2/orderbook': {
get: {
- description: `Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **per_page** query params apply to both \`bids\` and \`asks\` collections, and if \`page\` * \`per_page\` > \`total\` for a certain collection, the \`records\` for that collection should just be empty. `,
+ description: `Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **perPage** query params apply to both \`bids\` and \`asks\` collections, and if \`page\` * \`perPage\` > \`total\` for a certain collection, the \`records\` for that collection should just be empty. `,
operationId: 'getOrderbook',
parameters: generateParameters(
[
diff --git a/packages/sra-api/src/md/introduction.md b/packages/sra-api/src/md/introduction.md
index 3e5e84e4c..37c77cef9 100644
--- a/packages/sra-api/src/md/introduction.md
+++ b/packages/sra-api/src/md/introduction.md
@@ -6,13 +6,13 @@ Use the [sra-report](https://github.com/0xProject/0x-monorepo/tree/development/p
The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas). Examples of each payload and response can be found in the library's [test suite](https://github.com/0xProject/0x.js/blob/development/packages/json-schemas/test/schema_test.ts#L1).
-```
+```bash
npm install @0xproject/json-schemas --save
```
You can easily validate your API's payloads and responses using the [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas) package:
-```
+```js
import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';
const {relayerApiTokenPairsResponseSchema} = schemas;
@@ -26,13 +26,13 @@ const validatorResult: ValidatorResult = validator.validate(tokenPairsResponse,
# Pagination
-Requests that return potentially large collections should respond to the **?page** and **?per_page** parameters. For example:
+Requests that return potentially large collections should respond to the **?page** and **?perPage** parameters. For example:
-```
-$ curl https://api.example-relayer.com/v2/asset_pairs?page=3&per_page=20
+```bash
+$ curl https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20
```
-Page numbering should be 1-indexed, not 0-indexed. If a query provides an unreasonable (ie. too high) `per_page` value, the response can return a validation error as specified in the [errors section](#section/Errors). If the query specifies a `page` that does not exist (ie. there are not enough `records`), the response should just return an empty `records` array.
+Page numbering should be 1-indexed, not 0-indexed. If a query provides an unreasonable (ie. too high) `perPage` value, the response can return a validation error as specified in the [errors section](#section/Errors). If the query specifies a `page` that does not exist (ie. there are not enough `records`), the response should just return an empty `records` array.
All endpoints that are paginated should return a `total`, `page`, `perPage` and a `records` value in the top level of the collection. The value of `total` should be the total number of records for a given query, whereas `records` should be an array representing the response to the query for that page. `page` and `perPage`, are the same values that were specified in the request. See the note in [miscellaneous](#section/Misc.) about formatting `snake_case` vs. `lowerCamelCase`.
@@ -42,7 +42,7 @@ These requests include the [`/v2/asset_pairs`](#operation/getAssetPairs), [`/v2/
All requests should be able to specify a **?networkId** query param for all supported networks. For example:
-```
+```bash
$ curl https://api.example-relayer.com/v2/asset_pairs?networkId=1
```
@@ -59,7 +59,7 @@ Networks and their Ids:
If a certain network is not supported, the response should **400** as specified in the [error response](#section/Errors) section. For example:
-```
+```json
{
"code": 100,
"reason": "Validation failed",
@@ -78,9 +78,9 @@ If a certain network is not supported, the response should **400** as specified
A [Link Header](https://tools.ietf.org/html/rfc5988) can be included in a response to provide clients with more context about paging
For example:
-```
-Link: <https://api.example-relayer.com/v2/asset_pairs?page=3&per_page=20>; rel="next",
-<https://api.github.com/user/repos?page=10&per_page=20>; rel="last"
+```bash
+Link: <https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20>; rel="next",
+<https://api.github.com/user/repos?page=10&perPage=20>; rel="last"
```
This `Link` response header contains one or more Hypermedia link relations.
@@ -106,7 +106,7 @@ Rate limit guidance for clients can be optionally returned in the response heade
For example:
-```
+```bash
$ curl -i https://api.example-relayer.com/v2/asset_pairs
HTTP/1.1 200 OK
Date: Mon, 20 Oct 2017 12:30:06 GMT
@@ -136,7 +136,7 @@ Unless the spec defines otherwise, errors to bad requests should respond with HT
For all **400** responses, see the [error response schema](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_error_response_schema.ts#L1).
-```
+```json
{
"code": 101,
"reason": "Validation failed",
@@ -152,7 +152,7 @@ For all **400** responses, see the [error response schema](https://github.com/0x
General error codes:
-```
+```bash
100 - Validation Failed
101 - Malformed JSON
102 - Order submission disabled
@@ -161,7 +161,7 @@ General error codes:
Validation error codes:
-```
+```bash
1000 - Required field
1001 - Incorrect format
1002 - Invalid address
@@ -177,7 +177,7 @@ As we now support multiple [token transfer proxies](https://github.com/0xProject
The identifier for the Proxy uses a similar scheme to [ABI function selectors](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector).
-```
+```js
// ERC20 Proxy ID 0xf47261b0
bytes4(keccak256("ERC20Token(address)"))
// ERC721 Proxy ID 0x08e937fa
@@ -188,13 +188,13 @@ Asset data is encoded using [ABI encoding](https://solidity.readthedocs.io/en/de
For example, encoding the ERC20 token contract (address: 0x1dc4c1cefef38a777b15aa20260a54e584b16c48) using the ERC20 Transfer Proxy (id: 0xf47261b0) would be:
-```
+```bash
0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48
```
Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc74099f40e84`), token id (id: `99`, which hex encoded is `0x63`) and the ERC721 Transfer Proxy (id: 0x08e937fa) would be:
-```
+```bash
0x08e937fa000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063
```
@@ -211,4 +211,4 @@ A good example of such a field is `remainingTakerAssetAmount`, which is a conven
* All requests and responses should be of **application/json** content type
* All token amounts are sent in amounts of the smallest level of precision (base units). (e.g if a token has 18 decimal places, selling 1 token would show up as selling `'1000000000000000000'` units by this API).
* All addresses are sent as lower-case (non-checksummed) Ethereum addresses with the `0x` prefix.
-* All URL query parameters are to be written in `snake_case` and all queries and responses specified in JSON should use `lowerCamelCase`.
+* All parameters are to be written in `lowerCamelCase`.
diff --git a/packages/sra-api/src/parameters.ts b/packages/sra-api/src/parameters.ts
index 7d63a0a18..10382894c 100644
--- a/packages/sra-api/src/parameters.ts
+++ b/packages/sra-api/src/parameters.ts
@@ -10,7 +10,7 @@ export const paginationParameters: ParameterObject[] = [
},
},
{
- name: 'per_page',
+ name: 'perPage',
in: 'query',
description: 'The number of records to return per page.',
example: 10,
@@ -21,7 +21,7 @@ export const paginationParameters: ParameterObject[] = [
];
export const networkdIdParameter: ParameterObject = {
- name: 'network_id',
+ name: 'networkId',
in: 'query',
description: 'The id of the Ethereum network',
example: 42,