aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-api/src/json-schemas.ts
diff options
context:
space:
mode:
authorFrancesco Agosti <francesco.agosti93@gmail.com>2018-08-10 08:02:43 +0800
committerGitHub <noreply@github.com>2018-08-10 08:02:43 +0800
commit719699eb3072a85112107f3c76816909f53bce5a (patch)
tree6bb3ee193d62c3b6fdc6438fe6eb702d3db1f3d2 /packages/sra-api/src/json-schemas.ts
parentf97ec000e109341f7b200d0ff9ff324bf3f97d3e (diff)
parent889ec81ff332f755d3b7e414c4e48afb52123d9c (diff)
downloaddexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.tar
dexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.tar.gz
dexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.tar.bz2
dexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.tar.lz
dexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.tar.xz
dexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.tar.zst
dexon-sol-tools-719699eb3072a85112107f3c76816909f53bce5a.zip
Merge pull request #916 from 0xProject/feature/sra/add-sra-package
Add the sra-api package (OpenAPI Spec)
Diffstat (limited to 'packages/sra-api/src/json-schemas.ts')
-rw-r--r--packages/sra-api/src/json-schemas.ts63
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/sra-api/src/json-schemas.ts b/packages/sra-api/src/json-schemas.ts
new file mode 100644
index 000000000..173a04bfb
--- /dev/null
+++ b/packages/sra-api/src/json-schemas.ts
@@ -0,0 +1,63 @@
+import { schemas as jsonSchemas } from '@0xproject/json-schemas';
+
+// Only include schemas we actually need
+const {
+ numberSchema,
+ addressSchema,
+ hexSchema,
+ orderHashSchema,
+ orderSchema,
+ signedOrderSchema,
+ signedOrdersSchema,
+ ordersSchema,
+ paginatedCollectionSchema,
+ relayerApiErrorResponseSchema,
+ relayerApiFeeRecipientsResponseSchema,
+ relayerApiOrderSchema,
+ relayerApiOrdersSchema,
+ relayerApiOrderConfigPayloadSchema,
+ relayerApiOrderConfigResponseSchema,
+ relayerApiOrderbookResponseSchema,
+ relayerApiAssetDataPairsResponseSchema,
+ relayerApiAssetDataTradeInfoSchema,
+ relayerApiOrdersChannelSubscribeSchema,
+ relayerApiOrdersChannelSubscribePayload,
+ relayerApiOrdersChannelUpdateSchema,
+ relayerApiOrdersResponseSchema,
+ relayerApiAssetDataPairsSchema,
+} = jsonSchemas;
+
+const usedSchemas = {
+ numberSchema,
+ addressSchema,
+ hexSchema,
+ orderHashSchema,
+ orderSchema,
+ signedOrderSchema,
+ signedOrdersSchema,
+ ordersSchema,
+ paginatedCollectionSchema,
+ relayerApiErrorResponseSchema,
+ relayerApiFeeRecipientsResponseSchema,
+ relayerApiOrderSchema,
+ relayerApiOrdersSchema,
+ relayerApiOrderConfigPayloadSchema,
+ relayerApiOrderConfigResponseSchema,
+ relayerApiOrderbookResponseSchema,
+ relayerApiAssetDataPairsResponseSchema,
+ relayerApiAssetDataTradeInfoSchema,
+ relayerApiOrdersChannelSubscribeSchema,
+ relayerApiOrdersChannelSubscribePayload,
+ relayerApiOrdersChannelUpdateSchema,
+ relayerApiOrdersResponseSchema,
+ relayerApiAssetDataPairsSchema,
+};
+
+// We need to replace the `$ref`s to be OpenAPI compliant.
+const openApiSchemas = JSON.parse(
+ JSON.stringify(usedSchemas).replace(/(\/\w+)/g, match => `#/components/schemas${match}`),
+);
+// The json schema used by OpenAPI does not accept ids
+Object.keys(openApiSchemas).forEach(key => delete openApiSchemas[key].id);
+
+export const schemas = openApiSchemas;