aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-api/src
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-03 09:24:24 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-03 09:24:24 +0800
commit36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70 (patch)
tree93d3aee8f0381821d175713a8a31fd37899753c2 /packages/sra-api/src
parent0390a5ecbfc79dfd435d3f9e911abd610f33d455 (diff)
downloaddexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar
dexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.gz
dexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.bz2
dexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.lz
dexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.xz
dexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.tar.zst
dexon-sol-tools-36e7cb16aa086892ace18b2c6f3ed5a6e3b26a70.zip
Add errors and headers
Diffstat (limited to 'packages/sra-api/src')
-rw-r--r--packages/sra-api/src/api.ts48
-rw-r--r--packages/sra-api/src/examples/index.ts2
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,
};