Skip to content

Commit

Permalink
feat: deps update (#96)
Browse files Browse the repository at this point in the history
* fix: ùupdate depts

* style: prettier pass

* fix: prettier file

* style: eslint

* chore: dedupe

* Update package.json

Co-authored-by: Karol Maciaszek <karol@maciaszek.pl>

Co-authored-by: Karol Maciaszek <karol@maciaszek.pl>
  • Loading branch information
XVincentX and karol-maciaszek committed Jun 15, 2020
1 parent c4c8115 commit f2f0acb
Show file tree
Hide file tree
Showing 57 changed files with 1,839 additions and 1,524 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@stoplight"],
};
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require("@stoplight/eslint-config/prettier.config"),
};
51 changes: 26 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,54 @@
},
"scripts": {
"build": "sl-scripts build",
"lint": "tslint -c tslint.json 'src/**/*.ts' -p tsconfig.json",
"lint": "eslint 'src/**/*.ts'",
"lint.fix": "yarn lint --fix",
"release": "sl-scripts release",
"release.dryRun": "sl-scripts release --dry-run --debug",
"test": "jest"
},
"dependencies": {
"@openapi-contrib/openapi-schema-to-json-schema": "^3.0",
"@stoplight/json": "^3.5.1",
"@stoplight/types": "^11.5.0",
"@stoplight/json": "^3.7.3",
"@stoplight/types": "^11.6.0",
"@types/swagger-schema-official": "~2.0.21",
"@types/to-json-schema": "^0.2.0",
"@types/type-is": "^1.6.3",
"@types/urijs": "~1.19.7",
"@types/urijs": "~1.19.9",
"json-schema-generator": "^2.0.6",
"lodash": "^4.17.15",
"openapi3-ts": "~1.3.0",
"postman-collection": "^3.6.0",
"openapi3-ts": "~1.4.0",
"postman-collection": "^3.6.2",
"type-is": "^1.6.18",
"urijs": "~1.19.2"
},
"devDependencies": {
"@stoplight/scripts": "^8.2.0",
"@stoplight/eslint-config": "^1.1.0",
"@stoplight/scripts": "^8.2.1",
"@stoplight/test-utils": "^0.0.1",
"@types/jest": "25.1.4",
"@types/json-schema": "7.0.4",
"@types/lodash": "4.14.149",
"@types/jest": "26.0.0",
"@types/json-schema": "7.0.5",
"@types/lodash": "4.14.155",
"@types/postman-collection": "^3.5.3",
"jest": "25.1.0",
"prettier": "1.19.1",
"ts-jest": "25.2.1",
"ts-node": "^8.6.2",
"tslint": "6.1.0",
"tslint-config-prettier": "1.18.x",
"tslint-config-stoplight": "1.4.x",
"tslint-plugin-prettier": "2.2.0",
"typescript": "3.8.3",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@typescript-eslint/parser": "^3.2.0",
"eslint": "^7.2.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jest": "^23.13.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-simple-import-sort": "^5.0.3",
"jest": "26.0.1",
"prettier": "^2.0.5",
"ts-jest": "26.1.0",
"ts-node": "^8.10.2",
"typescript": "3.9.5",
"utility-types": "^3.10.0"
},
"lint-staged": {
"src/**/*.ts": [
"yarn tslint -c tslint.json --fix"
"yarn eslint --fix"
]
},
"husky": {
Expand All @@ -81,11 +87,6 @@
"@commitlint/config-conventional"
]
},
"prettier": {
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all"
},
"release": {
"extends": "@stoplight/scripts/release"
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/merge.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HttpParamStyles } from '@stoplight/types';

import { mergeOperations, mergeResponses } from '../merge';

describe('mergeResponses()', () => {
Expand Down
111 changes: 33 additions & 78 deletions src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,163 +1,118 @@
import * as urijs from 'urijs';

import { URI } from '../utils';

describe('URI()', () => {
test('instantiates from string', () => {
it('instantiates from string', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(URI(url).toString()).toEqual(url);
});

test('instantiates from urijs', () => {
it('instantiates from urijs', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(URI(urijs(url)).toString()).toEqual(url);
});

describe('type()', () => {
test('sets type', () => {
it('sets type', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.scheme('test2')
.toString(),
).toEqual('test2:///path/to/api.yaml#/the/pointer');
expect(URI(url).scheme('test2').toString()).toEqual('test2:///path/to/api.yaml#/the/pointer');
});
});

describe('host()', () => {
test('sets host', () => {
it('sets host', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.host('test2.com')
.toString(),
).toEqual('test://test2.com/path/to/api.yaml#/the/pointer');
expect(URI(url).host('test2.com').toString()).toEqual('test://test2.com/path/to/api.yaml#/the/pointer');
});

test('sets host and port', () => {
it('sets host and port', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.host('test2:3000')
.toString(),
).toEqual('test://test2:3000/path/to/api.yaml#/the/pointer');
expect(URI(url).host('test2:3000').toString()).toEqual('test://test2:3000/path/to/api.yaml#/the/pointer');
});

test('sets host and port (non-number port does not error)', () => {
it('sets host and port (non-number port does not error)', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.host('test2:{$$.env.host}')
.toString(),
).toEqual('test://test2:{$$.env.host}/path/to/api.yaml#/the/pointer');
expect(URI(url).host('test2:{$$.env.host}').toString()).toEqual(
'test://test2:{$$.env.host}/path/to/api.yaml#/the/pointer',
);
});
});

describe('port()', () => {
test('sets port', () => {
it('sets port', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.host('test2')
.port('3000')
.toString(),
).toEqual('test://test2:3000/path/to/api.yaml#/the/pointer');
expect(URI(url).host('test2').port('3000').toString()).toEqual('test://test2:3000/path/to/api.yaml#/the/pointer');
});

test('does not error on invalid port', () => {
it('does not error on invalid port', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.host('test2')
.port('invalid')
.toString(),
).toEqual('test://test2/path/to/api.yaml#/the/pointer');
expect(URI(url).host('test2').port('invalid').toString()).toEqual('test://test2/path/to/api.yaml#/the/pointer');
});
});

describe('path()', () => {
test('sets path', () => {
it('sets path', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.path('/path/to/other/api.yaml')
.toString(),
).toEqual('test:///path/to/other/api.yaml#/the/pointer');
expect(URI(url).path('/path/to/other/api.yaml').toString()).toEqual(
'test:///path/to/other/api.yaml#/the/pointer',
);
});
});

describe('pointer()', () => {
describe('pointer is a string', () => {
test('sets pointer', () => {
it('sets pointer', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.pointer('#/new/pointer')
.toString(),
).toEqual('test:///path/to/api.yaml#/new/pointer');
expect(URI(url).pointer('#/new/pointer').toString()).toEqual('test:///path/to/api.yaml#/new/pointer');
});
});

describe('pointer is a path', () => {
test('sets pointer', () => {
it('sets pointer', () => {
const url = 'test:///path/to/api.yaml#/the/pointer';

expect(
URI(url)
.pointer(['new', 'pointer'])
.toString(),
).toEqual('test:///path/to/api.yaml#/new/pointer');
expect(URI(url).pointer(['new', 'pointer']).toString()).toEqual('test:///path/to/api.yaml#/new/pointer');
});
});
});

describe('append()', () => {
describe('append pointer to uri having a pointer', () => {
it('replaces pointer', () => {
expect(
URI('file:///path/to/api.yaml#/some/pointer')
.append('#/some/other/pointer')
.toString(),
).toEqual('file:///path/to/api.yaml#/some/other/pointer');
expect(URI('file:///path/to/api.yaml#/some/pointer').append('#/some/other/pointer').toString()).toEqual(
'file:///path/to/api.yaml#/some/other/pointer',
);
});
});

describe('append element to uri having a pointer', () => {
it('appends element to pointer', () => {
expect(
URI('file:///path/to/api.yaml#/some/pointer')
.append('inner')
.toString(),
).toEqual('file:///path/to/api.yaml#/some/pointer/inner');
expect(URI('file:///path/to/api.yaml#/some/pointer').append('inner').toString()).toEqual(
'file:///path/to/api.yaml#/some/pointer/inner',
);
});
});

describe('append pointer to uri not having a pointer', () => {
it('appends pointer to uri', () => {
expect(
URI('file:///path/to/api.yaml')
.append('#/some')
.toString(),
).toEqual('file:///path/to/api.yaml#/some');
expect(URI('file:///path/to/api.yaml').append('#/some').toString()).toEqual('file:///path/to/api.yaml#/some');
});
});

describe('append element to uri not having a pointer', () => {
it('appends element to uri', () => {
expect(
URI('file:///path/to')
.append('api.yaml')
.toString(),
).toEqual('file:///path/to/api.yaml');
expect(URI('file:///path/to').append('api.yaml').toString()).toEqual('file:///path/to/api.yaml');
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/merge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IHttpHeaderParam, IHttpOperation, IHttpOperationResponse, IMediaTypeContent, IServer } from '@stoplight/types';
import { IHttpHeaderParam, IHttpOperation, IMediaTypeContent, IServer } from '@stoplight/types';

const mergeHeaders = mergeLists<IHttpHeaderParam[]>(
(h1, h2) => h1.name.toLowerCase() === h2.name.toLowerCase(),
Expand Down
14 changes: 7 additions & 7 deletions src/oas/__tests__/accessors.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getOasTags, getValidOasParameters } from '../accessors';

describe('getOasParameters', () => {
test('should return empty array', () => {
it('should return empty array', () => {
expect(getValidOasParameters(undefined, undefined)).toEqual([]);
});

test('should fallback to operation parameters', () => {
it('should fallback to operation parameters', () => {
expect(
getValidOasParameters(
[
Expand All @@ -26,7 +26,7 @@ describe('getOasParameters', () => {
]);
});

test('should fallback to path parameters', () => {
it('should fallback to path parameters', () => {
expect(
getValidOasParameters(undefined, [
{ name: 'n1', in: 'i1' },
Expand All @@ -44,7 +44,7 @@ describe('getOasParameters', () => {
]);
});

test('should prefer operation parameters', () => {
it('should prefer operation parameters', () => {
expect(
getValidOasParameters(
[
Expand Down Expand Up @@ -76,16 +76,16 @@ describe('getOasParameters', () => {

describe('getOasTags', () => {
describe.each([2, null, {}, '', 0])('when tags property is not an array', tags => {
test('should return empty array', () => {
it('should return empty array', () => {
expect(getOasTags(tags)).toEqual([]);
});
});

test('should filter out invalid values', () => {
it('should filter out invalid values', () => {
expect(getOasTags([{}, null, 'foo'])).toEqual(['foo']);
});

test('should normalize values', () => {
it('should normalize values', () => {
expect(getOasTags([0, 'foo', true])).toEqual(['0', 'foo', 'true']);
});
});
5 changes: 3 additions & 2 deletions src/oas/__tests__/operation.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { OpenAPIObject } from 'openapi3-ts';
import { Spec } from 'swagger-schema-official';

import { transformOas2Operations } from '../../oas2/operation';
import { transformOas3Operations } from '../../oas3/operation';

const oas2KitchenSinkJson: Spec = require('./fixtures//oas2-kitchen-sink.json');
const oas3KitchenSinkJson: OpenAPIObject = require('./fixtures//oas3-kitchen-sink.json');

describe('oas operation', () => {
test('openapi v2', () => {
it('openapi v2', () => {
expect(transformOas2Operations(oas2KitchenSinkJson)).toHaveLength(5);
});

test('openapi v3', () => {
it('openapi v3', () => {
expect(transformOas3Operations(oas3KitchenSinkJson)).toHaveLength(3);
});
});
7 changes: 3 additions & 4 deletions src/oas/__tests__/service.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { transformOas2Service } from '../../oas2/service';
import { transformOas3Service } from '../../oas3/service';

import * as oas2KitchenSinkJson from './fixtures//oas2-kitchen-sink.json';
import * as oas3KitchenSinkJson from './fixtures//oas3-kitchen-sink.json';

describe('oas service', () => {
test('openapi v2', () => {
it('openapi v2', () => {
expect(transformOas2Service({ document: oas2KitchenSinkJson as any })).toMatchSnapshot();
});

test('openapi v3', () => {
it('openapi v3', () => {
expect(transformOas3Service({ document: oas3KitchenSinkJson as any })).toMatchSnapshot();
});

test('openapi v2 and v3 should transform in the same way', () => {
it('openapi v2 and v3 should transform in the same way', () => {
const oas2MappedService = transformOas2Service({ document: oas2KitchenSinkJson as any });
const oas3MappedService = transformOas3Service({ document: oas3KitchenSinkJson as any });
expect(oas2MappedService).toEqual(oas3MappedService);
Expand Down
Loading

0 comments on commit f2f0acb

Please sign in to comment.