aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-api
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sra-api')
-rw-r--r--packages/sra-api/.npmignore8
-rw-r--r--packages/sra-api/CHANGELOG.json1
-rw-r--r--packages/sra-api/README.md57
-rw-r--r--packages/sra-api/package.json51
-rw-r--r--packages/sra-api/src/api.ts165
-rw-r--r--packages/sra-api/src/index.ts1
-rw-r--r--packages/sra-api/test/api_test.ts15
-rw-r--r--packages/sra-api/tsconfig.json7
-rw-r--r--packages/sra-api/tslint.json3
9 files changed, 308 insertions, 0 deletions
diff --git a/packages/sra-api/.npmignore b/packages/sra-api/.npmignore
new file mode 100644
index 000000000..5333847e7
--- /dev/null
+++ b/packages/sra-api/.npmignore
@@ -0,0 +1,8 @@
+.*
+yarn-error.log
+/src/
+/scripts/
+/schemas/
+test/
+tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/sra-api/CHANGELOG.json b/packages/sra-api/CHANGELOG.json
new file mode 100644
index 000000000..fe51488c7
--- /dev/null
+++ b/packages/sra-api/CHANGELOG.json
@@ -0,0 +1 @@
+[]
diff --git a/packages/sra-api/README.md b/packages/sra-api/README.md
new file mode 100644
index 000000000..8e3486bdf
--- /dev/null
+++ b/packages/sra-api/README.md
@@ -0,0 +1,57 @@
+## @0xproject/sra-api
+
+Contains the Standard Relayer API swagger spec.
+
+## Installation
+
+## Contributing
+
+We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
+
+```bash
+PKG=@0xproject/sra-api yarn build
+```
+
+Or continuously rebuild on change:
+
+```bash
+PKG=@0xproject/sra-api yarn watch
+```
+
+### Clean
+
+```bash
+yarn clean
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Run Tests
+
+```bash
+yarn test
+```
diff --git a/packages/sra-api/package.json b/packages/sra-api/package.json
new file mode 100644
index 000000000..8cbe911f3
--- /dev/null
+++ b/packages/sra-api/package.json
@@ -0,0 +1,51 @@
+{
+ "name": "@0xproject/sra-api",
+ "version": "0.0.1",
+ "engines": {
+ "node": ">=6.12"
+ },
+ "description": "Standard Relayer API Swagger Spec",
+ "main": "lib/src/index.js",
+ "types": "lib/src/index.d.ts",
+ "scripts": {
+ "lint": "tslint --project .",
+ "test": "yarn run_mocha",
+ "rebuild_and_test": "run-s clean build test",
+ "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",
+ "clean": "shx rm -rf lib test_temp scripts",
+ "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x-monorepo.git"
+ },
+ "author": "Francesco Agosti",
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x-monorepo/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-api/README.md",
+ "dependencies": {},
+ "devDependencies": {
+ "@0xproject/tslint-config": "^1.0.4",
+ "@loopback/openapi-v3-types": "^0.8.2",
+ "@types/mocha": "^2.2.42",
+ "chai": "^4.0.1",
+ "copyfiles": "^1.2.0",
+ "dirty-chai": "^2.0.1",
+ "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"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/sra-api/src/api.ts b/packages/sra-api/src/api.ts
new file mode 100644
index 000000000..9043f6245
--- /dev/null
+++ b/packages/sra-api/src/api.ts
@@ -0,0 +1,165 @@
+import { OpenApiSpec } from '@loopback/openapi-v3-types';
+
+export const api: OpenApiSpec = {
+ 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-api/src/index.ts b/packages/sra-api/src/index.ts
new file mode 100644
index 000000000..4d73f3cd3
--- /dev/null
+++ b/packages/sra-api/src/index.ts
@@ -0,0 +1 @@
+export { api } from './api';
diff --git a/packages/sra-api/test/api_test.ts b/packages/sra-api/test/api_test.ts
new file mode 100644
index 000000000..47353ca80
--- /dev/null
+++ b/packages/sra-api/test/api_test.ts
@@ -0,0 +1,15 @@
+import * as chai from 'chai';
+import * as dirtyChai from 'dirty-chai';
+import { validate } from 'openapi-schema-validation';
+
+import { api } from '../src/index';
+
+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-api/tsconfig.json b/packages/sra-api/tsconfig.json
new file mode 100644
index 000000000..e35816553
--- /dev/null
+++ b/packages/sra-api/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./src/**/*", "./test/**/*"]
+}
diff --git a/packages/sra-api/tslint.json b/packages/sra-api/tslint.json
new file mode 100644
index 000000000..ffaefe83a
--- /dev/null
+++ b/packages/sra-api/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": ["@0xproject/tslint-config"]
+}