From 81bbef808b86b1dd4f533d070c61dd88e534150f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 24 Jun 2019 12:12:34 +0200 Subject: [PATCH 1/6] feat(openapi-v3-types): deprecate this package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- packages/openapi-v3-types/README.md | 5 +++++ packages/openapi-v3-types/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/openapi-v3-types/README.md b/packages/openapi-v3-types/README.md index 30a5f3ab4ea8..494a22dc4707 100644 --- a/packages/openapi-v3-types/README.md +++ b/packages/openapi-v3-types/README.md @@ -7,6 +7,11 @@ TypeScript type definitions for OpenAPI Spec/Swagger documents. TypeScript definitions describing the schema of OpenAPI/Swagger documents, including LoopBack-specific extensions. +**This package is deprecated, use +[openapi3-ts](https://www.npmjs.com/package/openapi3-ts) or +[@loopback/openapi-v3](https://www.npmjs.com/package/@loopback/openapi-v3) +instead.** + ## Installation ```sh diff --git a/packages/openapi-v3-types/package.json b/packages/openapi-v3-types/package.json index 166ddd42555c..24c9d30868c4 100644 --- a/packages/openapi-v3-types/package.json +++ b/packages/openapi-v3-types/package.json @@ -1,7 +1,7 @@ { "name": "@loopback/openapi-v3-types", "version": "1.1.4", - "description": "TypeScript type definitions for OpenAPI Specifications.", + "description": "[DEPRECATED] TypeScript type definitions for OpenAPI Specifications.", "engines": { "node": ">=8.9" }, From 98eb4c3c573f50f0eaef7c077ae1bf488a9c8b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 24 Jun 2019 12:06:50 +0200 Subject: [PATCH 2/6] chore: remove unused dependency entries on openapi-v3-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- examples/todo-list/package.json | 1 - examples/todo/package.json | 1 - packages/cli/README.md | 1 - 3 files changed, 3 deletions(-) diff --git a/examples/todo-list/package.json b/examples/todo-list/package.json index d1b7613d8919..55c067631003 100644 --- a/examples/todo-list/package.json +++ b/examples/todo-list/package.json @@ -39,7 +39,6 @@ "@loopback/context": "^1.20.1", "@loopback/core": "^1.8.4", "@loopback/openapi-v3": "^1.6.4", - "@loopback/openapi-v3-types": "^1.1.4", "@loopback/repository": "^1.8.1", "@loopback/rest": "^1.16.2", "@loopback/rest-explorer": "^1.2.4", diff --git a/examples/todo/package.json b/examples/todo/package.json index 8a6a94fa47b7..5228b3b1ab73 100644 --- a/examples/todo/package.json +++ b/examples/todo/package.json @@ -39,7 +39,6 @@ "@loopback/context": "^1.20.1", "@loopback/core": "^1.8.4", "@loopback/openapi-v3": "^1.6.4", - "@loopback/openapi-v3-types": "^1.1.4", "@loopback/repository": "^1.8.1", "@loopback/rest": "^1.16.2", "@loopback/rest-explorer": "^1.2.4", diff --git a/packages/cli/README.md b/packages/cli/README.md index 9dbea47a24ce..b339322153b8 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -394,7 +394,6 @@ Run the following command to install the CLI. - @loopback/core: ^1.1.7 - @loopback/metadata: ^1.0.7 - @loopback/openapi-spec-builder: ^1.0.7 - - @loopback/openapi-v3-types: ^1.0.7 - @loopback/openapi-v3: ^1.2.3 - @loopback/repository-json-schema: ^1.3.3 - @loopback/repository: ^1.1.7 From 2f06c5516b4ba945bc6a324e3985bd285f71defe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 24 Jun 2019 12:08:32 +0200 Subject: [PATCH 3/6] docs: remove references to "@loopback/openapi-v3-types" package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- ...-the-API-using-design-first-approach.shelved.md | 14 ++++++++------ docs/site/Routes.md | 6 ++---- docs/site/Sequence.md | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/site/Defining-the-API-using-design-first-approach.shelved.md b/docs/site/Defining-the-API-using-design-first-approach.shelved.md index 89dc7564a798..aebb806dad13 100644 --- a/docs/site/Defining-the-API-using-design-first-approach.shelved.md +++ b/docs/site/Defining-the-API-using-design-first-approach.shelved.md @@ -341,13 +341,15 @@ import * as _ from 'lodash'; // Import API fragments here -export let spec = OpenApiSpec.createEmptyApiSpec(); -spec.info = { - title: 'Your API', - version: '1.0', +export const spec: OpenApiSpec = { + openapi: '3.0.0', + info: { + title: 'Your API', + version: '1.0', + }, + paths: {}, + servers: [{url: '/'}], }; -spec.swagger = '2.0'; -spec.basePath = '/'; _.merge(spec, ProductAPI); _.merge(spec, DealAPI); diff --git a/docs/site/Routes.md b/docs/site/Routes.md index 2aa2f99a1f65..7069d6a66bae 100644 --- a/docs/site/Routes.md +++ b/docs/site/Routes.md @@ -60,8 +60,7 @@ be confused with `x-operation-name`, which is a string for the Controller method name. ```ts -import {RestApplication} from '@loopback/rest'; -import {OpenApiSpec} from '@loopback/openapi-v3-types'; +import {OpenApiSpec, RestApplication} from '@loopback/rest'; function greet(name: string) { return `hello ${name}`; @@ -107,8 +106,7 @@ which is defined using `spec`. The route is then attached to a valid server context running underneath the application. ```ts -import {RestApplication, Route} from '@loopback/rest'; -import {OperationObject} from '@loopback/openapi-v3-types'; +import {OperationObject, RestApplication, Route} from '@loopback/rest'; const spec: OperationObject = { parameters: [{name: 'name', in: 'query', schema: {type: 'string'}}], diff --git a/docs/site/Sequence.md b/docs/site/Sequence.md index 0070978b3af6..e70a5a7f1a7c 100644 --- a/docs/site/Sequence.md +++ b/docs/site/Sequence.md @@ -47,7 +47,7 @@ building sequences, you use LoopBack Elements to respond to a request: docs link - [`OperationRetVal`](https://loopback.io/doc/en/lb4/apidocs.rest.operationretval.html) - [`ParseParams`](https://loopback.io/doc/en/lb4/apidocs.rest.parseparams.html) -- [`OpenAPISpec`](https://loopback.io/doc/en/lb4/apidocs.openapi-v3-types.openapispec.html) +- [`OpenAPISpec`](https://loopback.io/doc/en/lb4/apidocs.openapi-v3.openapispec.html) ## Actions From ca21afde245bd64d504b1826030786811a16cc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 24 Jun 2019 11:32:05 +0200 Subject: [PATCH 4/6] feat(openapi-v3): remove dependency on openapi-v3-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the definition of the type alias `OpenApiSpec` to a new file `types.ts`. Rework all imports from `@loopback/openapi-v3-types` to import from `types.ts` instead, remove the openapi-v3-types package from the dependencies too. Add the helper `createEmptyApiSpec()` to preserve backwards compatibility for code importing the helper from this package or its dependants like `@loopback/rest`. Signed-off-by: Miroslav Bajtoš --- packages/openapi-v3/package-lock.json | 5 ++++ packages/openapi-v3/package.json | 14 ++++----- .../controller-spec.integration.ts | 10 +++---- .../__tests__/unit/create-empty-spec.unit.ts | 28 +++++++++++++++++ .../param/param-query.decorator.unit.ts | 3 +- .../decorators/param/param.decorator.unit.ts | 10 +++++-- .../request-body-primitives.decorator.unit.ts | 9 +++--- .../src/__tests__/unit/json-to-schema.unit.ts | 6 ++-- packages/openapi-v3/src/controller-spec.ts | 20 ++++++------- .../src/decorators/operation.decorator.ts | 2 +- .../src/decorators/parameter.decorator.ts | 10 +++---- .../src/decorators/request-body.decorator.ts | 6 +--- packages/openapi-v3/src/filter-schema.ts | 2 +- packages/openapi-v3/src/generate-schema.ts | 2 +- packages/openapi-v3/src/index.ts | 8 ++--- packages/openapi-v3/src/json-to-schema.ts | 6 +--- packages/openapi-v3/src/keys.ts | 4 +-- packages/openapi-v3/src/types.ts | 30 +++++++++++++++++++ 18 files changed, 115 insertions(+), 60 deletions(-) create mode 100644 packages/openapi-v3/src/__tests__/unit/create-empty-spec.unit.ts create mode 100644 packages/openapi-v3/src/types.ts diff --git a/packages/openapi-v3/package-lock.json b/packages/openapi-v3/package-lock.json index 982640c19df2..88d41514d369 100644 --- a/packages/openapi-v3/package-lock.json +++ b/packages/openapi-v3/package-lock.json @@ -39,6 +39,11 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "openapi3-ts": { + "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/package.json b/packages/openapi-v3/package.json index e032846ad021..84579ac27de1 100644 --- a/packages/openapi-v3/package.json +++ b/packages/openapi-v3/package.json @@ -5,6 +5,13 @@ "engines": { "node": ">=8.9" }, + "dependencies": { + "@loopback/context": "^1.20.1", + "openapi3-ts": "^1.3.0", + "@loopback/repository-json-schema": "^1.7.2", + "debug": "^4.1.1", + "lodash": "^4.17.11" + }, "devDependencies": { "@loopback/build": "^2.0.2", "@loopback/eslint-config": "^1.1.2", @@ -46,12 +53,5 @@ "repository": { "type": "git", "url": "https://github.com/strongloop/loopback-next.git" - }, - "dependencies": { - "@loopback/context": "^1.20.1", - "@loopback/openapi-v3-types": "^1.1.4", - "@loopback/repository-json-schema": "^1.7.2", - "debug": "^4.1.1", - "lodash": "^4.17.11" } } diff --git a/packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts b/packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts index 4fe9325e6bc4..4fe388e8e271 100644 --- a/packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts +++ b/packages/openapi-v3/src/__tests__/integration/controller-spec.integration.ts @@ -3,11 +3,6 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import { - OperationObject, - ParameterObject, - SchemaObject, -} from '@loopback/openapi-v3-types'; import {Entity, model, property} from '@loopback/repository'; import {expect} from '@loopback/testlab'; import { @@ -15,10 +10,13 @@ import { ControllerSpec, get, getControllerSpec, + getModelSchemaRef, + OperationObject, param, + ParameterObject, post, requestBody, - getModelSchemaRef, + SchemaObject, } from '../..'; describe('controller spec', () => { diff --git a/packages/openapi-v3/src/__tests__/unit/create-empty-spec.unit.ts b/packages/openapi-v3/src/__tests__/unit/create-empty-spec.unit.ts new file mode 100644 index 000000000000..10cb6d1c1a66 --- /dev/null +++ b/packages/openapi-v3/src/__tests__/unit/create-empty-spec.unit.ts @@ -0,0 +1,28 @@ +// Copyright IBM Corp. 2019. All Rights Reserved. +// Node module: @loopback/openapi-v3 +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +import {expect} from '@loopback/testlab'; +import {createEmptyApiSpec} from '../../types'; + +describe('createEmptyApiSpec', () => { + it('sets version 3', () => { + expect(createEmptyApiSpec().openapi).to.equal('3.0.0'); + }); + + it('sets the spec info object', () => { + expect(createEmptyApiSpec().info).to.deepEqual({ + title: 'LoopBack Application', + version: '1.0.0', + }); + }); + + it('creates an empty paths object', () => { + expect(createEmptyApiSpec().paths).to.deepEqual({}); + }); + + it('creates a default servers array', () => { + expect(createEmptyApiSpec().servers).to.deepEqual([{url: '/'}]); + }); +}); diff --git a/packages/openapi-v3/src/__tests__/unit/decorators/param/param-query.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/param/param-query.decorator.unit.ts index 4fe10ade4394..12cb9a21b43a 100644 --- a/packages/openapi-v3/src/__tests__/unit/decorators/param/param-query.decorator.unit.ts +++ b/packages/openapi-v3/src/__tests__/unit/decorators/param/param-query.decorator.unit.ts @@ -3,9 +3,8 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {get, param, getControllerSpec} from '../../../..'; import {expect} from '@loopback/testlab'; -import {ParameterObject} from '@loopback/openapi-v3-types'; +import {get, getControllerSpec, param, ParameterObject} from '../../../..'; describe('Routing metadata for parameters', () => { describe('@param.query.string', () => { diff --git a/packages/openapi-v3/src/__tests__/unit/decorators/param/param.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/param/param.decorator.unit.ts index e1ba82907ea9..0156a038c4aa 100644 --- a/packages/openapi-v3/src/__tests__/unit/decorators/param/param.decorator.unit.ts +++ b/packages/openapi-v3/src/__tests__/unit/decorators/param/param.decorator.unit.ts @@ -4,13 +4,17 @@ // License text available at https://opensource.org/licenses/MIT import {anOperationSpec} from '@loopback/openapi-spec-builder'; +import {expect} from '@loopback/testlab'; import { + get, + getControllerSpec, + operation, OperationObject, + param, ParameterObject, + patch, ResponsesObject, -} from '@loopback/openapi-v3-types'; -import {expect} from '@loopback/testlab'; -import {get, getControllerSpec, operation, param, patch} from '../../../../'; +} from '../../../../'; describe('Routing metadata for parameters', () => { describe('@param', () => { diff --git a/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-primitives.decorator.unit.ts b/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-primitives.decorator.unit.ts index 4c734fc447d5..c6813e910738 100644 --- a/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-primitives.decorator.unit.ts +++ b/packages/openapi-v3/src/__tests__/unit/decorators/request-body/request-body-primitives.decorator.unit.ts @@ -3,15 +3,16 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT +import {Class} from '@loopback/repository'; +import {expect} from '@loopback/testlab'; import { + ContentObject, ControllerSpec, + getControllerSpec, post, requestBody, - getControllerSpec, + SchemaObject, } from '../../../../'; -import {ContentObject, SchemaObject} from '@loopback/openapi-v3-types'; -import {Class} from '@loopback/repository'; -import {expect} from '@loopback/testlab'; describe('requestBody decorator', () => { context('for a primitive type', () => { diff --git a/packages/openapi-v3/src/__tests__/unit/json-to-schema.unit.ts b/packages/openapi-v3/src/__tests__/unit/json-to-schema.unit.ts index 052014a35d16..40f53da46c3a 100644 --- a/packages/openapi-v3/src/__tests__/unit/json-to-schema.unit.ts +++ b/packages/openapi-v3/src/__tests__/unit/json-to-schema.unit.ts @@ -3,11 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {expect} from '@loopback/testlab'; - -import {SchemaObject} from '@loopback/openapi-v3-types'; -import {jsonToSchemaObject, jsonOrBooleanToJSON} from '../..'; import {JsonSchema} from '@loopback/repository-json-schema'; +import {expect} from '@loopback/testlab'; +import {jsonOrBooleanToJSON, jsonToSchemaObject, SchemaObject} from '../..'; describe('jsonToSchemaObject', () => { it('does nothing when given an empty object', () => { diff --git a/packages/openapi-v3/src/controller-spec.ts b/packages/openapi-v3/src/controller-spec.ts index 06251ba61532..9d62fdb576ea 100644 --- a/packages/openapi-v3/src/controller-spec.ts +++ b/packages/openapi-v3/src/controller-spec.ts @@ -4,6 +4,15 @@ // License text available at https://opensource.org/licenses/MIT import {DecoratorFactory, MetadataInspector} from '@loopback/context'; +import { + getJsonSchema, + getJsonSchemaRef, + JsonSchemaOptions, +} from '@loopback/repository-json-schema'; +import * as _ from 'lodash'; +import {resolveSchema} from './generate-schema'; +import {jsonToSchemaObject, SchemaRef} from './json-to-schema'; +import {OAI3Keys} from './keys'; import { ComponentsObject, ISpecificationExtension, @@ -16,16 +25,7 @@ import { ResponseObject, SchemaObject, SchemasObject, -} from '@loopback/openapi-v3-types'; -import { - getJsonSchema, - getJsonSchemaRef, - JsonSchemaOptions, -} from '@loopback/repository-json-schema'; -import * as _ from 'lodash'; -import {resolveSchema} from './generate-schema'; -import {jsonToSchemaObject, SchemaRef} from './json-to-schema'; -import {OAI3Keys} from './keys'; +} from './types'; const debug = require('debug')('loopback:openapi3:metadata:controller-spec'); diff --git a/packages/openapi-v3/src/decorators/operation.decorator.ts b/packages/openapi-v3/src/decorators/operation.decorator.ts index d92768c54849..ca62de42a629 100644 --- a/packages/openapi-v3/src/decorators/operation.decorator.ts +++ b/packages/openapi-v3/src/decorators/operation.decorator.ts @@ -3,10 +3,10 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {OperationObject} from '@loopback/openapi-v3-types'; import {MethodDecoratorFactory} from '@loopback/context'; import {RestEndpoint} from '../controller-spec'; import {OAI3Keys} from '../keys'; +import {OperationObject} from '../types'; /** * Expose a Controller method as a REST API operation diff --git a/packages/openapi-v3/src/decorators/parameter.decorator.ts b/packages/openapi-v3/src/decorators/parameter.decorator.ts index 114e3455820c..562a6f4e1eb2 100644 --- a/packages/openapi-v3/src/decorators/parameter.decorator.ts +++ b/packages/openapi-v3/src/decorators/parameter.decorator.ts @@ -3,16 +3,16 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT +import {MetadataInspector, ParameterDecoratorFactory} from '@loopback/context'; +import {resolveSchema} from '../generate-schema'; +import {OAI3Keys} from '../keys'; import { isSchemaObject, - ParameterObject, ParameterLocation, + ParameterObject, ReferenceObject, SchemaObject, -} from '@loopback/openapi-v3-types'; -import {MetadataInspector, ParameterDecoratorFactory} from '@loopback/context'; -import {resolveSchema} from '../generate-schema'; -import {OAI3Keys} from '../keys'; +} from '../types'; /** * Describe an input parameter of a Controller method. diff --git a/packages/openapi-v3/src/decorators/request-body.decorator.ts b/packages/openapi-v3/src/decorators/request-body.decorator.ts index fab17afbf6d7..4bae7cbfdfa5 100644 --- a/packages/openapi-v3/src/decorators/request-body.decorator.ts +++ b/packages/openapi-v3/src/decorators/request-body.decorator.ts @@ -4,15 +4,11 @@ // License text available at https://opensource.org/licenses/MIT import {MetadataInspector, ParameterDecoratorFactory} from '@loopback/context'; -import { - ReferenceObject, - RequestBodyObject, - SchemaObject, -} from '@loopback/openapi-v3-types'; import * as _ from 'lodash'; import {inspect} from 'util'; import {resolveSchema} from '../generate-schema'; import {OAI3Keys} from '../keys'; +import {ReferenceObject, RequestBodyObject, SchemaObject} from '../types'; const debug = require('debug')('loopback:openapi3:metadata:requestbody'); export const REQUEST_BODY_INDEX = 'x-parameter-index'; diff --git a/packages/openapi-v3/src/filter-schema.ts b/packages/openapi-v3/src/filter-schema.ts index 66f0bafd0ebd..664f34171f77 100644 --- a/packages/openapi-v3/src/filter-schema.ts +++ b/packages/openapi-v3/src/filter-schema.ts @@ -3,13 +3,13 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {SchemaObject} from '@loopback/openapi-v3-types'; import { getFilterJsonSchemaFor, getWhereJsonSchemaFor, Model, } from '@loopback/repository-json-schema'; import {jsonToSchemaObject} from './json-to-schema'; +import {SchemaObject} from './types'; /** * Build an OpenAPI schema describing the format of the "filter" object diff --git a/packages/openapi-v3/src/generate-schema.ts b/packages/openapi-v3/src/generate-schema.ts index b76e2d391d8f..5ffbda54ac3e 100644 --- a/packages/openapi-v3/src/generate-schema.ts +++ b/packages/openapi-v3/src/generate-schema.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {SchemaObject} from '@loopback/openapi-v3-types'; +import {SchemaObject} from './types'; /** * Generate the `type` and `format` property in a Schema Object according to a diff --git a/packages/openapi-v3/src/index.ts b/packages/openapi-v3/src/index.ts index 0602996cc48f..886c2412a730 100644 --- a/packages/openapi-v3/src/index.ts +++ b/packages/openapi-v3/src/index.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -export * from './decorators'; +export * from '@loopback/repository-json-schema'; export * from './controller-spec'; -export * from './json-to-schema'; +export * from './decorators'; export * from './filter-schema'; - -export * from '@loopback/repository-json-schema'; +export * from './json-to-schema'; +export * from './types'; diff --git a/packages/openapi-v3/src/json-to-schema.ts b/packages/openapi-v3/src/json-to-schema.ts index f62fd8e42640..f1307a7e2818 100644 --- a/packages/openapi-v3/src/json-to-schema.ts +++ b/packages/openapi-v3/src/json-to-schema.ts @@ -3,13 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import { - ReferenceObject, - SchemaObject, - SchemasObject, -} from '@loopback/openapi-v3-types'; import {JsonSchema} from '@loopback/repository-json-schema'; import * as _ from 'lodash'; +import {ReferenceObject, SchemaObject, SchemasObject} from './types'; /** * Custom LoopBack extension: a reference to Schema object that's bundled diff --git a/packages/openapi-v3/src/keys.ts b/packages/openapi-v3/src/keys.ts index a7bf4394d8f3..935cfc75ec85 100644 --- a/packages/openapi-v3/src/keys.ts +++ b/packages/openapi-v3/src/keys.ts @@ -4,8 +4,8 @@ // License text available at https://opensource.org/licenses/MIT import {MetadataAccessor} from '@loopback/context'; -import {RestEndpoint, ControllerSpec} from '.'; -import {ParameterObject, RequestBodyObject} from '@loopback/openapi-v3-types'; +import {ControllerSpec, RestEndpoint} from './controller-spec'; +import {ParameterObject, RequestBodyObject} from './types'; // Copyright IBM Corp. 2018. All Rights Reserved. // Node module: @loopback/openapi-v3 diff --git a/packages/openapi-v3/src/types.ts b/packages/openapi-v3/src/types.ts new file mode 100644 index 000000000000..c420f4fbc7ec --- /dev/null +++ b/packages/openapi-v3/src/types.ts @@ -0,0 +1,30 @@ +// Copyright IBM Corp. 2019. All Rights Reserved. +// Node module: @loopback/openapi-v3 +// This file is licensed under the MIT License. +// License text available at https://opensource.org/licenses/MIT + +import {OpenAPIObject} from 'openapi3-ts'; +/* + * OpenApiSpec - A typescript representation of OpenApi 3.0.0 + */ +export type OpenApiSpec = OpenAPIObject; + +// Export also all spec interfaces +export * from 'openapi3-ts'; + +/** + * Create an empty OpenApiSpec object that's still a valid openapi document. + * + * @deprecated Use `OpenApiBuilder` from `openapi3-ts` instead. + */ +export function createEmptyApiSpec(): OpenApiSpec { + return { + openapi: '3.0.0', + info: { + title: 'LoopBack Application', + version: '1.0.0', + }, + paths: {}, + servers: [{url: '/'}], + }; +} From efe881757ce5b79bfa2eae8d224be50edeb7fe4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 24 Jun 2019 11:39:32 +0200 Subject: [PATCH 5/6] refactor(openapi-spec-builder): remove dependency on openapi-v3-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework all imports from `@loopback/openapi-v3-types` to import from `types.ts` instead, remove the openapi-v3-types package from the dependencies too. Signed-off-by: Miroslav Bajtoš --- .../openapi-spec-builder/package-lock.json | 5 +++++ packages/openapi-spec-builder/package.json | 2 +- .../unit/openapi-spec-builder.unit.ts | 12 ++++++++++-- .../src/openapi-spec-builder.ts | 19 +++++++++++++------ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/packages/openapi-spec-builder/package-lock.json b/packages/openapi-spec-builder/package-lock.json index 3b832158c494..782be7b717e5 100644 --- a/packages/openapi-spec-builder/package-lock.json +++ b/packages/openapi-spec-builder/package-lock.json @@ -9,6 +9,11 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.10.tgz", "integrity": "sha512-V8wj+w2YMNvGuhgl/MA5fmTxgjmVHVoasfIaxMMZJV6Y8Kk+Ydpi1z2whoShDCJ2BuNVoqH/h1hrygnBxkrw/Q==", "dev": true + }, + "openapi3-ts": { + "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-spec-builder/package.json b/packages/openapi-spec-builder/package.json index ca2b74fb8d0b..da8f3a7a6c5a 100644 --- a/packages/openapi-spec-builder/package.json +++ b/packages/openapi-spec-builder/package.json @@ -23,7 +23,7 @@ "Testing" ], "dependencies": { - "@loopback/openapi-v3-types": "^1.1.4" + "openapi3-ts": "^1.3.0" }, "devDependencies": { "@loopback/build": "^2.0.2", diff --git a/packages/openapi-spec-builder/src/__tests__/unit/openapi-spec-builder.unit.ts b/packages/openapi-spec-builder/src/__tests__/unit/openapi-spec-builder.unit.ts index 14fcbab1c94b..827a17010088 100644 --- a/packages/openapi-spec-builder/src/__tests__/unit/openapi-spec-builder.unit.ts +++ b/packages/openapi-spec-builder/src/__tests__/unit/openapi-spec-builder.unit.ts @@ -3,15 +3,23 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {createEmptyApiSpec, ParameterObject} from '@loopback/openapi-v3-types'; import {expect} from '@loopback/testlab'; +import {ParameterObject} from 'openapi3-ts'; import {anOpenApiSpec, anOperationSpec} from '../../openapi-spec-builder'; describe('OpenAPI Spec Builder', () => { describe('anOpenApiSpec', () => { it('creates an empty spec', () => { const spec = anOpenApiSpec().build(); - expect(spec).to.eql(createEmptyApiSpec()); + expect(spec).to.eql({ + openapi: '3.0.0', + info: { + title: 'LoopBack Application', + version: '1.0.0', + }, + paths: {}, + servers: [{url: '/'}], + }); }); it('adds an extension', () => { diff --git a/packages/openapi-spec-builder/src/openapi-spec-builder.ts b/packages/openapi-spec-builder/src/openapi-spec-builder.ts index 451e21ad0771..8ffdbd523455 100644 --- a/packages/openapi-spec-builder/src/openapi-spec-builder.ts +++ b/packages/openapi-spec-builder/src/openapi-spec-builder.ts @@ -3,16 +3,15 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT +import * as assert from 'assert'; import { - createEmptyApiSpec, ISpecificationExtension, - OpenApiSpec, + OpenAPIObject, OperationObject, ParameterObject, RequestBodyObject, ResponseObject, -} from '@loopback/openapi-v3-types'; -import * as assert from 'assert'; +} from 'openapi3-ts'; /** * Create a new instance of OpenApiSpecBuilder. @@ -71,12 +70,20 @@ export class BuilderBase { /** * A builder for creating OpenApiSpec documents. */ -export class OpenApiSpecBuilder extends BuilderBase { +export class OpenApiSpecBuilder extends BuilderBase { /** * @param basePath - The base path on which the API is served. */ constructor() { - super(createEmptyApiSpec()); + super({ + openapi: '3.0.0', + info: { + title: 'LoopBack Application', + version: '1.0.0', + }, + paths: {}, + servers: [{url: '/'}], + }); } /** From 2c5b83f52678465efbf6bd2787778a5f8ba3ef81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 24 Jun 2019 11:57:57 +0200 Subject: [PATCH 6/6] refactor(rest): remove dependency on openapi-v3-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework all imports from `@loopback/openapi-v3-types` to import from `@loopback/openapi-v3` instead, remove the openapi-v3-types package from the dependencies too. Signed-off-by: Miroslav Bajtoš --- packages/rest/package.json | 1 - .../acceptance/routing/routing.acceptance.ts | 8 ++++++-- packages/rest/src/__tests__/helpers.ts | 2 +- .../integration/http-handler.integration.ts | 8 ++++++-- .../src/__tests__/unit/body-parser.unit.ts | 2 +- .../unit/coercion/invalid-spec.unit.test.ts | 4 ++-- .../unit/coercion/paramObject.unit.ts | 2 +- .../coercion/paramStringToBoolean.unit.ts | 4 ++-- .../unit/coercion/paramStringToBuffer.unit.ts | 4 ++-- .../unit/coercion/paramStringToDate.unit.ts | 4 ++-- .../coercion/paramStringToInteger.unit.ts | 4 ++-- .../unit/coercion/paramStringToNumber.unit.ts | 4 ++-- .../unit/coercion/paramStringToString.unit.ts | 2 +- .../coercion/parseStringToDatetime.unit.ts | 4 ++-- .../rest/src/__tests__/unit/coercion/utils.ts | 2 +- .../rest/src/__tests__/unit/parser.unit.ts | 2 +- .../unit/request-body.validator.test.ts | 2 +- packages/rest/src/body-parsers/body-parser.ts | 2 +- packages/rest/src/body-parsers/types.ts | 2 +- .../rest/src/coercion/coerce-parameter.ts | 2 +- packages/rest/src/coercion/validator.ts | 2 +- packages/rest/src/http-handler.ts | 19 ++++++++----------- packages/rest/src/index.ts | 1 - packages/rest/src/keys.ts | 2 +- packages/rest/src/parser.ts | 4 ++-- packages/rest/src/rest.application.ts | 2 +- packages/rest/src/rest.component.ts | 2 +- packages/rest/src/rest.server.ts | 4 ++-- packages/rest/src/router/base-route.ts | 2 +- packages/rest/src/router/controller-route.ts | 4 ++-- .../src/router/external-express-routes.ts | 2 +- packages/rest/src/router/handler-route.ts | 2 +- packages/rest/src/router/redirect-route.ts | 4 ++-- packages/rest/src/router/route-entry.ts | 2 +- packages/rest/src/router/router-spec.ts | 2 +- packages/rest/src/router/routing-table.ts | 4 ++-- packages/rest/src/types.ts | 2 +- .../src/validation/request-body.validator.ts | 2 +- 38 files changed, 65 insertions(+), 62 deletions(-) diff --git a/packages/rest/package.json b/packages/rest/package.json index 1162206e4032..a0abc626a772 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -23,7 +23,6 @@ "@loopback/core": "^1.8.4", "@loopback/http-server": "^1.4.3", "@loopback/openapi-v3": "^1.6.4", - "@loopback/openapi-v3-types": "^1.1.4", "@types/body-parser": "^1.17.0", "@types/cors": "^2.8.5", "@types/express": "^4.17.0", diff --git a/packages/rest/src/__tests__/acceptance/routing/routing.acceptance.ts b/packages/rest/src/__tests__/acceptance/routing/routing.acceptance.ts index 2ded222aa0c2..d54f9b919f4b 100644 --- a/packages/rest/src/__tests__/acceptance/routing/routing.acceptance.ts +++ b/packages/rest/src/__tests__/acceptance/routing/routing.acceptance.ts @@ -6,12 +6,16 @@ import {BindingScope, Constructor, Context, inject} from '@loopback/context'; import {Application, CoreBindings} from '@loopback/core'; import {anOpenApiSpec, anOperationSpec} from '@loopback/openapi-spec-builder'; -import {api, get, param, post, requestBody} from '@loopback/openapi-v3'; import { + api, + get, OperationObject, + param, ParameterObject, + post, + requestBody, ResponseObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import { Client, createClientForHandler, diff --git a/packages/rest/src/__tests__/helpers.ts b/packages/rest/src/__tests__/helpers.ts index 44af5807507f..cbccafeed452 100644 --- a/packages/rest/src/__tests__/helpers.ts +++ b/packages/rest/src/__tests__/helpers.ts @@ -7,7 +7,7 @@ import { ReferenceObject, RequestBodyObject, SchemaObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import {RestServerConfig, RestServerResolvedConfig} from '../rest.server'; /** diff --git a/packages/rest/src/__tests__/integration/http-handler.integration.ts b/packages/rest/src/__tests__/integration/http-handler.integration.ts index dfac50b9430b..f8bb174afba0 100644 --- a/packages/rest/src/__tests__/integration/http-handler.integration.ts +++ b/packages/rest/src/__tests__/integration/http-handler.integration.ts @@ -5,8 +5,12 @@ import {Context} from '@loopback/context'; import {anOpenApiSpec, anOperationSpec} from '@loopback/openapi-spec-builder'; -import {ControllerSpec, get} from '@loopback/openapi-v3'; -import {ParameterObject, RequestBodyObject} from '@loopback/openapi-v3-types'; +import { + ControllerSpec, + get, + ParameterObject, + RequestBodyObject, +} from '@loopback/openapi-v3'; import { Client, createClientForHandler, diff --git a/packages/rest/src/__tests__/unit/body-parser.unit.ts b/packages/rest/src/__tests__/unit/body-parser.unit.ts index 3217b5ca0282..7088d1993292 100644 --- a/packages/rest/src/__tests__/unit/body-parser.unit.ts +++ b/packages/rest/src/__tests__/unit/body-parser.unit.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {Context} from '@loopback/core'; -import {OperationObject, RequestBodyObject} from '@loopback/openapi-v3-types'; +import {OperationObject, RequestBodyObject} from '@loopback/openapi-v3'; import { expect, ShotRequestOptions, diff --git a/packages/rest/src/__tests__/unit/coercion/invalid-spec.unit.test.ts b/packages/rest/src/__tests__/unit/coercion/invalid-spec.unit.test.ts index 203bd12dc539..f8191a95f2f1 100644 --- a/packages/rest/src/__tests__/unit/coercion/invalid-spec.unit.test.ts +++ b/packages/rest/src/__tests__/unit/coercion/invalid-spec.unit.test.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../../'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {test} from './utils'; const INVALID_PARAM = { in: 'unknown', diff --git a/packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts index 2d1bc4ef1c54..10fa9997fa7c 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramObject.unit.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ParameterObject} from '@loopback/openapi-v3-types'; +import {ParameterObject} from '@loopback/openapi-v3'; import * as qs from 'qs'; import {RestHttpErrors} from '../../..'; import {test} from './utils'; diff --git a/packages/rest/src/__tests__/unit/coercion/paramStringToBoolean.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToBoolean.unit.ts index 4297701e3810..711fd1275035 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramStringToBoolean.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToBoolean.unit.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../../'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {test} from './utils'; const BOOLEAN_PARAM = { in: 'path', diff --git a/packages/rest/src/__tests__/unit/coercion/paramStringToBuffer.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToBuffer.unit.ts index 58e8839810a5..e03d9a98cd50 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramStringToBuffer.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToBuffer.unit.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../..'; +import {test} from './utils'; const BUFFER_PARAM = { in: 'path', diff --git a/packages/rest/src/__tests__/unit/coercion/paramStringToDate.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToDate.unit.ts index c3c2887f6ebd..f72947041a7b 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramStringToDate.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToDate.unit.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../../'; +import {test} from './utils'; const DATE_PARAM = { in: 'path', diff --git a/packages/rest/src/__tests__/unit/coercion/paramStringToInteger.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToInteger.unit.ts index 3f1b71f7b5aa..2e1cf85f207f 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramStringToInteger.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToInteger.unit.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../../'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {test} from './utils'; const INT32_PARAM = { in: 'path', diff --git a/packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts index e20fc0fe12be..a93997a5138d 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToNumber.unit.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../../'; +import {test} from './utils'; const NUMBER_PARAM = { in: 'path', diff --git a/packages/rest/src/__tests__/unit/coercion/paramStringToString.unit.ts b/packages/rest/src/__tests__/unit/coercion/paramStringToString.unit.ts index 1f539778bda1..0989044180bb 100644 --- a/packages/rest/src/__tests__/unit/coercion/paramStringToString.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/paramStringToString.unit.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ParameterObject} from '@loopback/openapi-v3-types'; +import {ParameterObject} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../..'; import {test} from './utils'; diff --git a/packages/rest/src/__tests__/unit/coercion/parseStringToDatetime.unit.ts b/packages/rest/src/__tests__/unit/coercion/parseStringToDatetime.unit.ts index 0c3447a22499..a2e5644471c9 100644 --- a/packages/rest/src/__tests__/unit/coercion/parseStringToDatetime.unit.ts +++ b/packages/rest/src/__tests__/unit/coercion/parseStringToDatetime.unit.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {test} from './utils'; +import {ParameterLocation} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../../../'; -import {ParameterLocation} from '@loopback/openapi-v3-types'; +import {test} from './utils'; const DATETIME_PARAM = { in: 'path', diff --git a/packages/rest/src/__tests__/unit/coercion/utils.ts b/packages/rest/src/__tests__/unit/coercion/utils.ts index 7a802bf01f0e..5dcb0257bb3e 100644 --- a/packages/rest/src/__tests__/unit/coercion/utils.ts +++ b/packages/rest/src/__tests__/unit/coercion/utils.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {OperationObject, ParameterObject} from '@loopback/openapi-v3-types'; +import {OperationObject, ParameterObject} from '@loopback/openapi-v3'; import { expect, ShotRequestOptions, diff --git a/packages/rest/src/__tests__/unit/parser.unit.ts b/packages/rest/src/__tests__/unit/parser.unit.ts index 38095759e5f7..ebe0c480b432 100644 --- a/packages/rest/src/__tests__/unit/parser.unit.ts +++ b/packages/rest/src/__tests__/unit/parser.unit.ts @@ -9,7 +9,7 @@ import { ParameterObject, RequestBodyObject, SchemaObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import { expect, ShotRequestOptions, diff --git a/packages/rest/src/__tests__/unit/request-body.validator.test.ts b/packages/rest/src/__tests__/unit/request-body.validator.test.ts index 16cb0f690641..079d21c117c7 100644 --- a/packages/rest/src/__tests__/unit/request-body.validator.test.ts +++ b/packages/rest/src/__tests__/unit/request-body.validator.test.ts @@ -7,7 +7,7 @@ import { ReferenceObject, SchemaObject, SchemasObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import {expect} from '@loopback/testlab'; import {RestHttpErrors, validateRequestBody} from '../../'; import {aBodySpec} from '../helpers'; diff --git a/packages/rest/src/body-parsers/body-parser.ts b/packages/rest/src/body-parsers/body-parser.ts index 86beab53b428..355b964fb834 100644 --- a/packages/rest/src/body-parsers/body-parser.ts +++ b/packages/rest/src/body-parsers/body-parser.ts @@ -11,7 +11,7 @@ import { inject, instantiateClass, } from '@loopback/context'; -import {isReferenceObject, OperationObject} from '@loopback/openapi-v3-types'; +import {isReferenceObject, OperationObject} from '@loopback/openapi-v3'; import * as debugModule from 'debug'; import {is} from 'type-is'; import {RestHttpErrors} from '../rest-http-error'; diff --git a/packages/rest/src/body-parsers/types.ts b/packages/rest/src/body-parsers/types.ts index 410acfa74ab7..874acc3578bb 100644 --- a/packages/rest/src/body-parsers/types.ts +++ b/packages/rest/src/body-parsers/types.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ReferenceObject, SchemaObject} from '@loopback/openapi-v3-types'; +import {ReferenceObject, SchemaObject} from '@loopback/openapi-v3'; import {Request} from '../types'; /** * Request body with metadata diff --git a/packages/rest/src/coercion/coerce-parameter.ts b/packages/rest/src/coercion/coerce-parameter.ts index c94640db09c7..fe82566a2f65 100644 --- a/packages/rest/src/coercion/coerce-parameter.ts +++ b/packages/rest/src/coercion/coerce-parameter.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {isReferenceObject, ParameterObject} from '@loopback/openapi-v3-types'; +import {isReferenceObject, ParameterObject} from '@loopback/openapi-v3'; import * as debugModule from 'debug'; import {RestHttpErrors} from '../'; import {parseJson} from '../parse-json'; diff --git a/packages/rest/src/coercion/validator.ts b/packages/rest/src/coercion/validator.ts index 6ca2fecbdd8e..0e1f2ff8e6e7 100644 --- a/packages/rest/src/coercion/validator.ts +++ b/packages/rest/src/coercion/validator.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ParameterObject, SchemaObject} from '@loopback/openapi-v3-types'; +import {ParameterObject, SchemaObject} from '@loopback/openapi-v3'; import {RestHttpErrors} from '../'; /** diff --git a/packages/rest/src/http-handler.ts b/packages/rest/src/http-handler.ts index fe532bd5eaaa..d66e392f9c5d 100644 --- a/packages/rest/src/http-handler.ts +++ b/packages/rest/src/http-handler.ts @@ -4,23 +4,20 @@ // License text available at https://opensource.org/licenses/MIT import {Context} from '@loopback/context'; -import {PathObject, SchemasObject} from '@loopback/openapi-v3-types'; -import {ControllerSpec} from '@loopback/openapi-v3'; - -import {SequenceHandler} from './sequence'; +import {ControllerSpec, PathObject, SchemasObject} from '@loopback/openapi-v3'; +import {RestBindings} from './keys'; +import {RequestContext} from './request-context'; +import {RestServerResolvedConfig} from './rest.server'; import { - RoutingTable, - ResolvedRoute, - RouteEntry, ControllerClass, ControllerFactory, + ResolvedRoute, + RouteEntry, + RoutingTable, } from './router'; +import {SequenceHandler} from './sequence'; import {Request, Response} from './types'; -import {RestBindings} from './keys'; -import {RequestContext} from './request-context'; -import {RestServerResolvedConfig} from './rest.server'; - export class HttpHandler { protected _apiDefinitions: SchemasObject; diff --git a/packages/rest/src/index.ts b/packages/rest/src/index.ts index 88bfe3d3e379..18dc947518b3 100644 --- a/packages/rest/src/index.ts +++ b/packages/rest/src/index.ts @@ -27,4 +27,3 @@ import * as HttpErrors from 'http-errors'; export {HttpErrors}; export * from '@loopback/openapi-v3'; -export * from '@loopback/openapi-v3-types'; diff --git a/packages/rest/src/keys.ts b/packages/rest/src/keys.ts index 47309d781a89..fb12039be7c5 100644 --- a/packages/rest/src/keys.ts +++ b/packages/rest/src/keys.ts @@ -6,7 +6,7 @@ import {BindingKey, Context} from '@loopback/context'; import {CoreBindings} from '@loopback/core'; import {HttpProtocol} from '@loopback/http-server'; -import {OpenApiSpec} from '@loopback/openapi-v3-types'; +import {OpenApiSpec} from '@loopback/openapi-v3'; import * as https from 'https'; import {ErrorWriterOptions} from 'strong-error-handler'; import {BodyParser, RequestBodyParser} from './body-parsers'; diff --git a/packages/rest/src/parser.ts b/packages/rest/src/parser.ts index 8731cfa098e6..757cfc1d46ab 100644 --- a/packages/rest/src/parser.ts +++ b/packages/rest/src/parser.ts @@ -3,13 +3,13 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {REQUEST_BODY_INDEX} from '@loopback/openapi-v3'; import { isReferenceObject, OperationObject, ParameterObject, + REQUEST_BODY_INDEX, SchemasObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import * as debugFactory from 'debug'; import {RequestBody, RequestBodyParser} from './body-parsers'; import {coerceParameter} from './coercion/coerce-parameter'; diff --git a/packages/rest/src/rest.application.ts b/packages/rest/src/rest.application.ts index b44f429982a1..dd30fa8137b2 100644 --- a/packages/rest/src/rest.application.ts +++ b/packages/rest/src/rest.application.ts @@ -5,7 +5,7 @@ import {Binding, BindingAddress, Constructor} from '@loopback/context'; import {Application, ApplicationConfig, Server} from '@loopback/core'; -import {OpenApiSpec, OperationObject} from '@loopback/openapi-v3-types'; +import {OpenApiSpec, OperationObject} from '@loopback/openapi-v3'; import {PathParams} from 'express-serve-static-core'; import {ServeStaticOptions} from 'serve-static'; import {format} from 'util'; diff --git a/packages/rest/src/rest.component.ts b/packages/rest/src/rest.component.ts index 1fbe2e711d4a..ea9f6c88a895 100644 --- a/packages/rest/src/rest.component.ts +++ b/packages/rest/src/rest.component.ts @@ -11,7 +11,7 @@ import { ProviderMap, Server, } from '@loopback/core'; -import {createEmptyApiSpec} from '@loopback/openapi-v3-types'; +import {createEmptyApiSpec} from '@loopback/openapi-v3'; import { JsonBodyParser, RequestBodyParser, diff --git a/packages/rest/src/rest.server.ts b/packages/rest/src/rest.server.ts index 8ff56b3d817a..6fedc63ee5f1 100644 --- a/packages/rest/src/rest.server.ts +++ b/packages/rest/src/rest.server.ts @@ -13,12 +13,12 @@ import { } from '@loopback/context'; import {Application, CoreBindings, Server} from '@loopback/core'; import {HttpServer, HttpServerOptions} from '@loopback/http-server'; -import {getControllerSpec} from '@loopback/openapi-v3'; import { + getControllerSpec, OpenApiSpec, OperationObject, ServerObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import {AssertionError} from 'assert'; import * as cors from 'cors'; import * as debugFactory from 'debug'; diff --git a/packages/rest/src/router/base-route.ts b/packages/rest/src/router/base-route.ts index a72ea6311ab9..cc2a8175e2f2 100644 --- a/packages/rest/src/router/base-route.ts +++ b/packages/rest/src/router/base-route.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {Context} from '@loopback/context'; -import {OperationObject} from '@loopback/openapi-v3-types'; +import {OperationObject} from '@loopback/openapi-v3'; import {OperationArgs, OperationRetval} from '../types'; import {RouteEntry} from './route-entry'; diff --git a/packages/rest/src/router/controller-route.ts b/packages/rest/src/router/controller-route.ts index 9071aa556352..77c033f0adb7 100644 --- a/packages/rest/src/router/controller-route.ts +++ b/packages/rest/src/router/controller-route.ts @@ -4,15 +4,15 @@ // License text available at https://opensource.org/licenses/MIT import { + BindingScope, Constructor, Context, instantiateClass, invokeMethod, ValueOrPromise, - BindingScope, } from '@loopback/context'; import {CoreBindings} from '@loopback/core'; -import {OperationObject} from '@loopback/openapi-v3-types'; +import {OperationObject} from '@loopback/openapi-v3'; import * as HttpErrors from 'http-errors'; import {OperationArgs, OperationRetval} from '../types'; import {BaseRoute} from './base-route'; diff --git a/packages/rest/src/router/external-express-routes.ts b/packages/rest/src/router/external-express-routes.ts index e41a4ce7fabc..4a28d5c6175d 100644 --- a/packages/rest/src/router/external-express-routes.ts +++ b/packages/rest/src/router/external-express-routes.ts @@ -8,7 +8,7 @@ import { OpenApiSpec, OperationObject, SchemasObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import * as express from 'express'; import {RequestHandler} from 'express'; import {PathParams} from 'express-serve-static-core'; diff --git a/packages/rest/src/router/handler-route.ts b/packages/rest/src/router/handler-route.ts index 5d972fa16823..3ebf5f754662 100644 --- a/packages/rest/src/router/handler-route.ts +++ b/packages/rest/src/router/handler-route.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {Context, invokeMethodWithInterceptors} from '@loopback/context'; -import {OperationObject} from '@loopback/openapi-v3-types'; +import {OperationObject} from '@loopback/openapi-v3'; import {OperationArgs, OperationRetval} from '../types'; import {BaseRoute} from './base-route'; diff --git a/packages/rest/src/router/redirect-route.ts b/packages/rest/src/router/redirect-route.ts index cd990edc1098..7e8f2ba494ad 100644 --- a/packages/rest/src/router/redirect-route.ts +++ b/packages/rest/src/router/redirect-route.ts @@ -3,9 +3,9 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {RouteEntry, ResolvedRoute} from '.'; +import {OperationObject, SchemasObject} from '@loopback/openapi-v3'; +import {ResolvedRoute, RouteEntry} from '.'; import {RequestContext} from '../request-context'; -import {OperationObject, SchemasObject} from '@loopback/openapi-v3-types'; import {OperationArgs, OperationRetval, PathParameterValues} from '../types'; export class RedirectRoute implements RouteEntry, ResolvedRoute { diff --git a/packages/rest/src/router/route-entry.ts b/packages/rest/src/router/route-entry.ts index 9acca7af7df9..b7f7be3833ed 100644 --- a/packages/rest/src/router/route-entry.ts +++ b/packages/rest/src/router/route-entry.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {Context} from '@loopback/context'; -import {OperationObject, SchemasObject} from '@loopback/openapi-v3-types'; +import {OperationObject, SchemasObject} from '@loopback/openapi-v3'; import {OperationArgs, OperationRetval, PathParameterValues} from '../types'; /** diff --git a/packages/rest/src/router/router-spec.ts b/packages/rest/src/router/router-spec.ts index 6ac78cdefbfb..2943c0cf932e 100644 --- a/packages/rest/src/router/router-spec.ts +++ b/packages/rest/src/router/router-spec.ts @@ -3,7 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {OpenApiSpec} from '@loopback/openapi-v3-types'; +import {OpenApiSpec} from '@loopback/openapi-v3'; export type RouterSpec = Pick; diff --git a/packages/rest/src/router/routing-table.ts b/packages/rest/src/router/routing-table.ts index a64345084aa7..d99bab053ee7 100644 --- a/packages/rest/src/router/routing-table.ts +++ b/packages/rest/src/router/routing-table.ts @@ -3,12 +3,12 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import {ControllerSpec} from '@loopback/openapi-v3'; import { + ControllerSpec, OperationObject, ParameterObject, PathObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import * as assert from 'assert'; import * as debugFactory from 'debug'; import * as HttpErrors from 'http-errors'; diff --git a/packages/rest/src/types.ts b/packages/rest/src/types.ts index 58738c4565e8..7b1db3f5299d 100644 --- a/packages/rest/src/types.ts +++ b/packages/rest/src/types.ts @@ -4,7 +4,7 @@ // License text available at https://opensource.org/licenses/MIT import {Binding, BoundValue} from '@loopback/context'; -import {ReferenceObject, SchemaObject} from '@loopback/openapi-v3-types'; +import {ReferenceObject, SchemaObject} from '@loopback/openapi-v3'; import * as ajv from 'ajv'; import { Options, diff --git a/packages/rest/src/validation/request-body.validator.ts b/packages/rest/src/validation/request-body.validator.ts index b96957f70404..21941ad7c0a6 100644 --- a/packages/rest/src/validation/request-body.validator.ts +++ b/packages/rest/src/validation/request-body.validator.ts @@ -8,7 +8,7 @@ import { RequestBodyObject, SchemaObject, SchemasObject, -} from '@loopback/openapi-v3-types'; +} from '@loopback/openapi-v3'; import * as AJV from 'ajv'; import * as debugModule from 'debug'; import * as _ from 'lodash';