diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-15 05:21:47 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-15 05:21:47 +0800 |
commit | 2f2582a0da3095d61a99ef09744dc0995677558e (patch) | |
tree | 54989565919038c42d495dafb7426d4148605e84 /packages/sra-api/src/json-schemas.ts | |
parent | 8169155a6547fb0283cd0f5362aad3c0b173b00b (diff) | |
parent | fadd292ecf367e42154856509d0ea0c20b23f2f1 (diff) | |
download | dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.gz dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.bz2 dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.lz dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.xz dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.zst dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.zip |
Merge development
Diffstat (limited to 'packages/sra-api/src/json-schemas.ts')
-rw-r--r-- | packages/sra-api/src/json-schemas.ts | 63 |
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; |