Rename to sra-api
This commit is contained in:
8
packages/sra-api/.npmignore
Normal file
8
packages/sra-api/.npmignore
Normal file
@@ -0,0 +1,8 @@
|
||||
.*
|
||||
yarn-error.log
|
||||
/src/
|
||||
/scripts/
|
||||
/schemas/
|
||||
test/
|
||||
tsconfig.json
|
||||
/lib/src/monorepo_scripts/
|
||||
1
packages/sra-api/CHANGELOG.json
Normal file
1
packages/sra-api/CHANGELOG.json
Normal file
@@ -0,0 +1 @@
|
||||
[]
|
||||
57
packages/sra-api/README.md
Normal file
57
packages/sra-api/README.md
Normal file
@@ -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
|
||||
```
|
||||
51
packages/sra-api/package.json
Normal file
51
packages/sra-api/package.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
165
packages/sra-api/src/api.ts
Normal file
165
packages/sra-api/src/api.ts
Normal file
@@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
1
packages/sra-api/src/index.ts
Normal file
1
packages/sra-api/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { api } from './api';
|
||||
15
packages/sra-api/test/api_test.ts
Normal file
15
packages/sra-api/test/api_test.ts
Normal file
@@ -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);
|
||||
});
|
||||
});
|
||||
7
packages/sra-api/tsconfig.json
Normal file
7
packages/sra-api/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["./src/**/*", "./test/**/*"]
|
||||
}
|
||||
3
packages/sra-api/tslint.json
Normal file
3
packages/sra-api/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["@0xproject/tslint-config"]
|
||||
}
|
||||
Reference in New Issue
Block a user