From d7528049b2fb0f4d8109a366068c7c823841ed8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 27 May 2019 13:47:49 +0200 Subject: [PATCH 1/2] refactor(rest): remove workaround for TypeScript bug that has been fixed by now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- packages/rest/package-lock.json | 5 ----- packages/rest/package.json | 1 - packages/rest/src/keys.ts | 27 ++++++++++----------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/packages/rest/package-lock.json b/packages/rest/package-lock.json index 3ac188894ed8..a31fd1ddc82b 100644 --- a/packages/rest/package-lock.json +++ b/packages/rest/package-lock.json @@ -871,11 +871,6 @@ "deep-equal": "^1.0.1" } }, - "openapi3-ts": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/openapi3-ts/-/openapi3-ts-1.2.0.tgz", - "integrity": "sha512-oWRW8aI58UPD1ufx54y4QOCwqdQPedCRBKmqgwRUtetz4+NUJD2opWn3a0Te4yLzlFdf9eGinrKvc3uvD2Wegw==" - }, "os-locale": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", diff --git a/packages/rest/package.json b/packages/rest/package.json index e46bc4c75fe9..1ab211b525a5 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -43,7 +43,6 @@ "lodash": "^4.17.11", "on-finished": "^2.3.0", "openapi-schema-to-json-schema": "^2.1.0", - "openapi3-ts": "^1.0.0", "path-to-regexp": "^3.0.0", "qs": "^6.5.2", "strong-error-handler": "^3.2.0", diff --git a/packages/rest/src/keys.ts b/packages/rest/src/keys.ts index 2c67bff9b4ee..47309d781a89 100644 --- a/packages/rest/src/keys.ts +++ b/packages/rest/src/keys.ts @@ -3,16 +3,15 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {CoreBindings} from '@loopback/core'; import {BindingKey, Context} from '@loopback/context'; - -/** - * See https://github.com/Microsoft/TypeScript/issues/26985 - */ -// import {OpenApiSpec} from '@loopback/openapi-v3-types'; -import {OpenAPIObject as OpenApiSpec} from 'openapi3-ts'; - +import {CoreBindings} from '@loopback/core'; +import {HttpProtocol} from '@loopback/http-server'; +import {OpenApiSpec} from '@loopback/openapi-v3-types'; +import * as https from 'https'; +import {ErrorWriterOptions} from 'strong-error-handler'; +import {BodyParser, RequestBodyParser} from './body-parsers'; import {HttpHandler} from './http-handler'; +import {RestRouter, RestRouterOptions} from './router'; import {SequenceHandler} from './sequence'; import { BindElement, @@ -20,20 +19,14 @@ import { GetFromContext, InvokeMethod, LogError, - Request, - Response, ParseParams, Reject, - Send, + Request, RequestBodyParserOptions, + Response, + Send, } from './types'; -import {HttpProtocol} from '@loopback/http-server'; -import * as https from 'https'; -import {ErrorWriterOptions} from 'strong-error-handler'; -import {RestRouter, RestRouterOptions} from './router'; -import {RequestBodyParser, BodyParser} from './body-parsers'; - /** * RestServer-specific bindings */ From 070dbe40e77575219c342b70ca478457b3743708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 27 May 2019 13:41:43 +0200 Subject: [PATCH 2/2] chore(openapi-v3-types): update openapi3-ts to 1.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- packages/openapi-v3-types/package-lock.json | 6 +++--- packages/openapi-v3-types/package.json | 2 +- packages/openapi-v3-types/src/index.ts | 1 - packages/openapi-v3-types/src/type-guards.ts | 21 -------------------- 4 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 packages/openapi-v3-types/src/type-guards.ts diff --git a/packages/openapi-v3-types/package-lock.json b/packages/openapi-v3-types/package-lock.json index 737367f5d56c..8977413b78a7 100644 --- a/packages/openapi-v3-types/package-lock.json +++ b/packages/openapi-v3-types/package-lock.json @@ -11,9 +11,9 @@ "dev": true }, "openapi3-ts": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/openapi3-ts/-/openapi3-ts-1.2.0.tgz", - "integrity": "sha512-oWRW8aI58UPD1ufx54y4QOCwqdQPedCRBKmqgwRUtetz4+NUJD2opWn3a0Te4yLzlFdf9eGinrKvc3uvD2Wegw==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/openapi3-ts/-/openapi3-ts-1.3.0.tgz", + "integrity": "sha512-Xk3hsB0PzB4dzr/r/FdmK+VfQbZH7lQQ2iipMS1/1eoz1wUvh5R7rmOakYvw0bQJJE6PYrOLx8UHsYmzgTr+YQ==" } } } diff --git a/packages/openapi-v3-types/package.json b/packages/openapi-v3-types/package.json index 95b64dd5e8d8..09791e91986b 100644 --- a/packages/openapi-v3-types/package.json +++ b/packages/openapi-v3-types/package.json @@ -6,7 +6,7 @@ "node": ">=8.9" }, "dependencies": { - "openapi3-ts": "^1.0.0" + "openapi3-ts": "^1.3.0" }, "devDependencies": { "@loopback/build": "^1.5.5", diff --git a/packages/openapi-v3-types/src/index.ts b/packages/openapi-v3-types/src/index.ts index 7b50105e02d2..08ea08e44b2a 100644 --- a/packages/openapi-v3-types/src/index.ts +++ b/packages/openapi-v3-types/src/index.ts @@ -4,4 +4,3 @@ // License text available at https://opensource.org/licenses/MIT export * from './openapi-v3-spec-types'; -export * from './type-guards'; diff --git a/packages/openapi-v3-types/src/type-guards.ts b/packages/openapi-v3-types/src/type-guards.ts deleted file mode 100644 index 41619bf57c26..000000000000 --- a/packages/openapi-v3-types/src/type-guards.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright IBM Corp. 2018. All Rights Reserved. -// Node module: @loopback/openapi-v3-types -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -import {SchemaObject, ReferenceObject} from './openapi-v3-spec-types'; - -/** - * Type guard for OpenAPI 3.0.0 schema object - * @param schema - An OpenAPI 3.0.0 schema object - */ - -export function isSchemaObject( - schema: SchemaObject | ReferenceObject, -): schema is SchemaObject { - return !schema.hasOwnProperty('$ref'); -} - -export function isReferenceObject(obj: object): obj is ReferenceObject { - return obj.hasOwnProperty('$ref'); -}