aboutsummaryrefslogtreecommitdiffstats
path: root/packages
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 /packages
parent3ca4b7e7a76b4a9397fa00962571a472ca30eda1 (diff)
downloaddexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.gz
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.bz2
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.lz
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.xz
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.tar.zst
dexon-sol-tools-260976914d42519bd90f281c08065c2727660fbe.zip
Add basic smoke test
Diffstat (limited to 'packages')
-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
7 files changed, 181 insertions, 7 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';