aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-07-27 05:30:24 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-07-27 05:30:24 +0800
commit260976914d42519bd90f281c08065c2727660fbe (patch)
tree059a4407145fe381f1012d1ac9c1ced8b0d19cf3
parent3ca4b7e7a76b4a9397fa00962571a472ca30eda1 (diff)
downloaddexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.gz
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.zst
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.zip
Add basic smoke test
-rw-r--r--packages/sra/README.md2
-rw-r--r--packages/sra/package.json4
-rw-r--r--packages/sra/src/api.ts163
-rw-r--r--packages/sra/src/index.ts1
-rw-r--r--packages/sra/test/api_test.ts14
-rw-r--r--packages/sra/test/sample_test.ts3
-rw-r--r--packages/typescript-typings/types/openapi-schema-validation/index.d.ts1
-rw-r--r--yarn.lock91
8 files changed, 201 insertions, 78 deletions
diff --git a/packages/sra/README.md b/packages/sra/README.md
index 461c93b44..a70760121 100644
--- a/packages/sra/README.md
+++ b/packages/sra/README.md
@@ -4,8 +4,6 @@ Contains the Standard Relayer API swagger spec and publishes the client libs.
## Installation
-_pending_
-
## Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
diff --git a/packages/sra/package.json b/packages/sra/package.json
index f7f5becf9..47faafd92 100644
--- a/packages/sra/package.json
+++ b/packages/sra/package.json
@@ -14,8 +14,7 @@
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage",
- "run_mocha":
- "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
+ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
"clean": "shx rm -rf lib test_temp scripts",
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts"
},
@@ -39,6 +38,7 @@
"make-promises-safe": "^1.1.0",
"mocha": "^4.0.1",
"nyc": "^11.0.1",
+ "openapi-schema-validation": "^0.4.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typescript": "2.7.1"
diff --git a/packages/sra/src/api.ts b/packages/sra/src/api.ts
new file mode 100644
index 000000000..98b5ce96a
--- /dev/null
+++ b/packages/sra/src/api.ts
@@ -0,0 +1,163 @@
+export const api = {
+ openapi: '3.0.0',
+ info: {
+ version: '1.0.0',
+ title: 'Swagger Petstore',
+ license: {
+ name: 'MIT',
+ },
+ },
+ servers: [
+ {
+ url: 'http://petstore.swagger.io/v1',
+ },
+ ],
+ paths: {
+ '/pets': {
+ get: {
+ summary: 'List all pets',
+ operationId: 'listPets',
+ tags: ['pets'],
+ parameters: [
+ {
+ name: 'limit',
+ in: 'query',
+ description: 'How many items to return at one time (max 100)',
+ required: false,
+ schema: {
+ type: 'integer',
+ format: 'int32',
+ },
+ },
+ ],
+ responses: {
+ '200': {
+ description: 'An paged array of pets',
+ headers: {
+ 'x-next': {
+ description: 'A link to the next page of responses',
+ schema: {
+ type: 'string',
+ },
+ },
+ },
+ content: {
+ 'application/json': {
+ schema: {
+ $ref: '#/components/schemas/Pets',
+ },
+ },
+ },
+ },
+ default: {
+ description: 'unexpected error',
+ content: {
+ 'application/json': {
+ schema: {
+ $ref: '#/components/schemas/Error',
+ },
+ },
+ },
+ },
+ },
+ },
+ post: {
+ summary: 'Create a pet',
+ operationId: 'createPets',
+ tags: ['pets'],
+ responses: {
+ '201': {
+ description: 'Null response',
+ },
+ default: {
+ description: 'unexpected error',
+ content: {
+ 'application/json': {
+ schema: {
+ $ref: '#/components/schemas/Error',
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ '/pets/{petId}': {
+ get: {
+ summary: 'Info for a specific pet',
+ operationId: 'showPetById',
+ tags: ['pets'],
+ parameters: [
+ {
+ name: 'petId',
+ in: 'path',
+ required: true,
+ description: 'The id of the pet to retrieve',
+ schema: {
+ type: 'string',
+ },
+ },
+ ],
+ responses: {
+ '200': {
+ description: 'Expected response to a valid request',
+ content: {
+ 'application/json': {
+ schema: {
+ $ref: '#/components/schemas/Pets',
+ },
+ },
+ },
+ },
+ default: {
+ description: 'unexpected error',
+ content: {
+ 'application/json': {
+ schema: {
+ $ref: '#/components/schemas/Error',
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ components: {
+ schemas: {
+ Pet: {
+ required: ['id', 'name'],
+ properties: {
+ id: {
+ type: 'integer',
+ format: 'int64',
+ },
+ name: {
+ type: 'string',
+ },
+ tag: {
+ type: 'string',
+ },
+ },
+ },
+ Pets: {
+ type: 'array',
+ items: {
+ $ref: '#/components/schemas/Pet',
+ },
+ },
+ Error: {
+ required: ['code', 'message'],
+ properties: {
+ code: {
+ type: 'integer',
+ format: 'int32',
+ },
+ message: {
+ type: 'string',
+ },
+ },
+ },
+ },
+ },
+};
diff --git a/packages/sra/src/index.ts b/packages/sra/src/index.ts
index e69de29bb..4d73f3cd3 100644
--- a/packages/sra/src/index.ts
+++ b/packages/sra/src/index.ts
@@ -0,0 +1 @@
+export { api } from './api';
diff --git a/packages/sra/test/api_test.ts b/packages/sra/test/api_test.ts
new file mode 100644
index 000000000..dcc10d8b8
--- /dev/null
+++ b/packages/sra/test/api_test.ts
@@ -0,0 +1,14 @@
+import * as chai from 'chai';
+import * as dirtyChai from 'dirty-chai';
+import { api } from '../src/api';
+import { validate } from 'openapi-schema-validation';
+
+chai.config.includeStack = true;
+chai.use(dirtyChai);
+
+describe('SRA OpenAPI Schema', () => {
+ it('should be a valid OpenAPI schema', () => {
+ const result = validate(api, 3);
+ chai.expect(result.errors).to.have.length(0);
+ });
+});
diff --git a/packages/sra/test/sample_test.ts b/packages/sra/test/sample_test.ts
deleted file mode 100644
index e7edd6719..000000000
--- a/packages/sra/test/sample_test.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-describe('test', () => {
- it('should pass', () => undefined);
-});
diff --git a/packages/typescript-typings/types/openapi-schema-validation/index.d.ts b/packages/typescript-typings/types/openapi-schema-validation/index.d.ts
new file mode 100644
index 000000000..123a6bdb7
--- /dev/null
+++ b/packages/typescript-typings/types/openapi-schema-validation/index.d.ts
@@ -0,0 +1 @@
+declare module 'openapi-schema-validation';
diff --git a/yarn.lock b/yarn.lock
index 804ba85a8..853d5c8d7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -565,37 +565,6 @@
lodash "4.17.10"
uuid "3.2.1"
-"@0xproject/contract-wrappers@^1.0.1-rc.2":
- version "1.0.1-rc.1"
- dependencies:
- "@0xproject/assert" "^1.0.3"
- "@0xproject/base-contract" "^1.0.3"
- "@0xproject/fill-scenarios" "^1.0.1-rc.1"
- "@0xproject/json-schemas" "^1.0.1-rc.2"
- "@0xproject/order-utils" "^1.0.1-rc.1"
- "@0xproject/types" "^1.0.1-rc.2"
- "@0xproject/typescript-typings" "^1.0.3"
- "@0xproject/utils" "^1.0.3"
- "@0xproject/web3-wrapper" "^1.1.1"
- ethereum-types "^1.0.3"
- ethereumjs-blockstream "5.0.0"
- ethereumjs-util "^5.1.1"
- ethers "3.0.22"
- js-sha3 "^0.7.0"
- lodash "^4.17.4"
- uuid "^3.1.0"
-
-"@0xproject/dev-utils@^1.0.3":
- version "1.0.2"
- dependencies:
- "@0xproject/subproviders" "^1.0.3"
- "@0xproject/types" "^1.0.1-rc.2"
- "@0xproject/typescript-typings" "^1.0.3"
- "@0xproject/utils" "^1.0.3"
- "@0xproject/web3-wrapper" "^1.1.1"
- ethereum-types "^1.0.3"
- lodash "^4.17.4"
-
"@0xproject/fill-scenarios@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@0xproject/fill-scenarios/-/fill-scenarios-0.0.4.tgz#4d23c75abda7e9f117b698c0b8b142af07e0c69e"
@@ -653,23 +622,6 @@
jsonschema "1.2.2"
lodash.values "4.3.0"
-"@0xproject/migrations@^1.0.3":
- version "1.0.2"
- dependencies:
- "@0xproject/base-contract" "^1.0.3"
- "@0xproject/order-utils" "^1.0.1-rc.1"
- "@0xproject/sol-compiler" "^1.0.3"
- "@0xproject/subproviders" "^1.0.3"
- "@0xproject/typescript-typings" "^1.0.3"
- "@0xproject/utils" "^1.0.3"
- "@0xproject/web3-wrapper" "^1.1.1"
- "@ledgerhq/hw-app-eth" "^4.3.0"
- ethereum-types "^1.0.3"
- ethers "3.0.22"
- lodash "^4.17.4"
- optionalDependencies:
- "@ledgerhq/hw-transport-node-hid" "^4.3.0"
-
"@0xproject/order-utils@^0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@0xproject/order-utils/-/order-utils-0.0.7.tgz#eaa465782ea5745bdad54e1a851533172d993b7c"
@@ -718,25 +670,6 @@
ethereumjs-util "5.1.5"
lodash "4.17.10"
-"@0xproject/order-utils@^1.0.1-rc.2":
- version "1.0.1-rc.1"
- dependencies:
- "@0xproject/assert" "^1.0.3"
- "@0xproject/base-contract" "^1.0.3"
- "@0xproject/json-schemas" "^1.0.1-rc.2"
- "@0xproject/sol-compiler" "^1.0.3"
- "@0xproject/types" "^1.0.1-rc.2"
- "@0xproject/typescript-typings" "^1.0.3"
- "@0xproject/utils" "^1.0.3"
- "@0xproject/web3-wrapper" "^1.1.1"
- "@types/node" "^8.0.53"
- bn.js "^4.11.8"
- ethereum-types "^1.0.3"
- ethereumjs-abi "0.6.5"
- ethereumjs-util "^5.1.1"
- ethers "3.0.22"
- lodash "^4.17.4"
-
"@0xproject/order-watcher@^0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@0xproject/order-watcher/-/order-watcher-0.0.7.tgz#fbe019aa33447781096b5d562e7a3a4ec91a1da2"
@@ -5203,9 +5136,9 @@ ethereumjs-wallet@~0.6.0:
utf8 "^2.1.1"
uuid "^2.0.1"
-ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22:
- version "3.0.18"
- resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447"
+ethers@3.0.22:
+ version "3.0.22"
+ resolved "https://registry.npmjs.org/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436"
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"
@@ -7702,7 +7635,11 @@ jsonparse@^1.2.0:
version "1.3.1"
resolved "http://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
-jsonschema@*, jsonschema@^1.2.0:
+jsonschema-draft4@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.npmjs.org/jsonschema-draft4/-/jsonschema-draft4-1.0.0.tgz#f0af2005054f0f0ade7ea2118614b69dc512d865"
+
+jsonschema@*, jsonschema@1.2.4, jsonschema@^1.2.0:
version "1.2.4"
resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.4.tgz#a46bac5d3506a254465bc548876e267c6d0d6464"
@@ -9373,6 +9310,14 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"
+openapi-schema-validation@^0.4.1:
+ version "0.4.1"
+ resolved "https://registry.npmjs.org/openapi-schema-validation/-/openapi-schema-validation-0.4.1.tgz#927e1277082ef61688239730470bfbbdd0f1268d"
+ dependencies:
+ jsonschema "1.2.4"
+ jsonschema-draft4 "^1.0.0"
+ swagger-schema-official "2.0.0-bab6bed"
+
opn-cli@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/opn-cli/-/opn-cli-3.1.0.tgz#f819ae6cae0b411bd0149b8560fe6c88adad20f8"
@@ -12511,6 +12456,10 @@ svgo@^0.7.0:
sax "~1.2.1"
whet.extend "~0.9.9"
+swagger-schema-official@2.0.0-bab6bed:
+ version "2.0.0-bab6bed"
+ resolved "https://registry.npmjs.org/swagger-schema-official/-/swagger-schema-official-2.0.0-bab6bed.tgz#70070468d6d2977ca5237b2e519ca7d06a2ea3fd"
+
swarm-js@0.1.37:
version "0.1.37"
resolved "https://registry.yarnpkg.com/swarm-js/-/swarm-js-0.1.37.tgz#27d485317a340bbeec40292af783cc10acfa4663"