diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-08-03 09:24:24 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-08-03 09:24:24 +0800 |
commit | 36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70 (patch) | |
tree | 93d3aee8f0381821d175713a8a31fd37899753c2 | |
parent | 0390a5ecbfc79dfd435d3f9e911abd610f33d455 (diff) | |
download | dexon-0x-contracts-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.gz dexon-0x-contracts-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.zst dexon-0x-contracts-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.zip |
Add errors and headers
-rw-r--r-- | packages/sra-api/src/api.ts | 48 | ||||
-rw-r--r-- | packages/sra-api/src/examples/index.ts | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/packages/sra-api/src/api.ts b/packages/sra-api/src/api.ts index 7d2cc6e08..2a43e3e8e 100644 --- a/packages/sra-api/src/api.ts +++ b/packages/sra-api/src/api.ts @@ -37,6 +37,51 @@ const networkdIdParameter = { }, }; +const headers = { + 'X-Rate-Limit-Limit': { + description: `The maximum number of requests you're permitted to make per hour.`, + schema: { + type: 'integer', + }, + }, + 'X-Rate-Limit-Remaining': { + description: 'The number of requests remaining in the current rate limit window.', + schema: { + type: 'integer', + }, + }, + 'X-Rate-Limit-Reset': { + description: 'The time at which the current rate limit window resets in UTC epoch seconds.', + schema: { + type: 'integer', + }, + }, +}; + +const errorResponses = { + '400': { + description: 'Validation error', + content: { + 'application/json': { + schema: { $ref: '#/components/schemas/relayerApiErrorResponseSchema' }, + example: examples.validationError, + }, + }, + }, + '404': { + description: 'Not found', + }, + '429': { + description: 'Too many requests - Rate limit exceeded', + }, + '500': { + description: 'Internal Server Error', + }, + '501': { + description: 'Not implemented.', + }, +}; + export const api: OpenApiSpec = { openapi: '3.0.0', info: { @@ -82,6 +127,8 @@ export const api: OpenApiSpec = { ], responses: { '200': { + headers, + description: 'OK', content: { 'application/json': { schema: { $ref: '#/components/schemas/relayerApiAssetDataPairsResponseSchema' }, @@ -89,6 +136,7 @@ export const api: OpenApiSpec = { }, }, }, + ...errorResponses, }, }, }, diff --git a/packages/sra-api/src/examples/index.ts b/packages/sra-api/src/examples/index.ts index 10ecd182c..eeeb353b3 100644 --- a/packages/sra-api/src/examples/index.ts +++ b/packages/sra-api/src/examples/index.ts @@ -1,5 +1,7 @@ +import { validationError } from './errors'; import { relayerApiAssetDataPairsResponseSchema } from './relayerApiAssetDataPairsResponseSchema'; export const examples = { + validationError, relayerApiAssetDataPairsResponseSchema, }; |