@loopback/openapi-v3 5.3.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/build-responses-from-metadata.js +3 -1
- package/dist/build-responses-from-metadata.js.map +1 -1
- package/dist/controller-spec.js +10 -10
- package/dist/controller-spec.js.map +1 -1
- package/dist/decorators/deprecated.decorator.js +1 -1
- package/dist/decorators/index.js +8 -8
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/parameter.decorator.js +5 -5
- package/dist/decorators/parameter.decorator.js.map +1 -1
- package/dist/decorators/request-body.decorator.js +5 -5
- package/dist/decorators/request-body.decorator.js.map +1 -1
- package/dist/decorators/response.decorator.js +1 -1
- package/dist/decorators/response.decorator.js.map +1 -1
- package/dist/decorators/tags.decorator.js +1 -1
- package/dist/decorators/visibility.decorator.js +1 -1
- package/dist/enhancers/index.js +3 -3
- package/dist/enhancers/index.js.map +1 -1
- package/dist/enhancers/spec-enhancer.service.js +9 -9
- package/dist/enhancers/spec-enhancer.service.js.map +1 -1
- package/dist/enhancers/types.js +1 -1
- package/dist/enhancers/types.js.map +1 -1
- package/dist/filter-schema.js +6 -6
- package/dist/filter-schema.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/json-to-schema.js +2 -2
- package/dist/json-to-schema.js.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +17 -17
- package/src/build-responses-from-metadata.ts +7 -3
- package/src/controller-spec.ts +29 -24
- package/src/decorators/deprecated.decorator.ts +1 -1
- package/src/decorators/tags.decorator.ts +1 -1
- package/src/decorators/visibility.decorator.ts +1 -1
- package/src/enhancers/spec-enhancer.service.ts +1 -1
- package/CHANGELOG.md +0 -1506
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/openapi-v3",
|
|
3
3
|
"description": "Decorators that annotate LoopBack artifacts with OpenAPI v3 metadata and utilities that transform LoopBack metadata to OpenAPI v3 specifications",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Swagger",
|
|
7
7
|
"OpenAPI Spec",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"copyright.owner": "IBM Corp.",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/loopbackio/loopback-next.git",
|
|
18
18
|
"directory": "packages/openapi-v3"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
@@ -39,28 +39,28 @@
|
|
|
39
39
|
"!*/__tests__"
|
|
40
40
|
],
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@loopback/core": "^2.
|
|
42
|
+
"@loopback/core": "^2.18.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@loopback/repository-json-schema": "^
|
|
46
|
-
"debug": "^4.3.
|
|
45
|
+
"@loopback/repository-json-schema": "^4.0.2",
|
|
46
|
+
"debug": "^4.3.2",
|
|
47
47
|
"http-status": "^1.5.0",
|
|
48
|
-
"json-merge-patch": "^1.0.
|
|
48
|
+
"json-merge-patch": "^1.0.2",
|
|
49
49
|
"lodash": "^4.17.21",
|
|
50
50
|
"openapi3-ts": "^2.0.1",
|
|
51
|
-
"tslib": "^2.
|
|
51
|
+
"tslib": "^2.3.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@loopback/build": "^
|
|
55
|
-
"@loopback/core": "^2.
|
|
56
|
-
"@loopback/eslint-config": "^
|
|
57
|
-
"@loopback/openapi-spec-builder": "^3.2.
|
|
58
|
-
"@loopback/repository": "^3.
|
|
59
|
-
"@loopback/testlab": "^3.4.
|
|
60
|
-
"@types/debug": "^4.1.
|
|
54
|
+
"@loopback/build": "^7.0.2",
|
|
55
|
+
"@loopback/core": "^2.18.0",
|
|
56
|
+
"@loopback/eslint-config": "^11.0.2",
|
|
57
|
+
"@loopback/openapi-spec-builder": "^3.2.4",
|
|
58
|
+
"@loopback/repository": "^3.7.3",
|
|
59
|
+
"@loopback/testlab": "^3.4.4",
|
|
60
|
+
"@types/debug": "^4.1.7",
|
|
61
61
|
"@types/json-merge-patch": "0.0.5",
|
|
62
|
-
"@types/lodash": "^4.14.
|
|
63
|
-
"@types/node": "^10.17.
|
|
62
|
+
"@types/lodash": "^4.14.175",
|
|
63
|
+
"@types/node": "^10.17.60"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "d9a29c85dbe38f12ba219d8c495cf6038bbc3590"
|
|
66
66
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
|
-
import {DecoratorFactory} from '@loopback/core';
|
|
7
|
-
import {Model} from '@loopback/repository';
|
|
6
|
+
import {DecoratorFactory, MetadataInspector} from '@loopback/core';
|
|
7
|
+
import {Model, MODEL_KEY} from '@loopback/repository';
|
|
8
8
|
import {
|
|
9
9
|
ContentObject,
|
|
10
10
|
OperationObject,
|
|
@@ -21,7 +21,11 @@ declare type ResponseMap = Map<
|
|
|
21
21
|
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
23
|
function isModel<T extends Model>(c: any): c is T {
|
|
24
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
c?.prototype instanceof Model ||
|
|
26
|
+
// Allowing classes decorated with `@model` but not extending from `Model`
|
|
27
|
+
MetadataInspector.getClassMetadata(MODEL_KEY, c) != null
|
|
28
|
+
);
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
package/src/controller-spec.ts
CHANGED
|
@@ -95,10 +95,11 @@ function resolveControllerSpec(constructor: Function): ControllerSpec {
|
|
|
95
95
|
constructor,
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
const classVisibility =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const classVisibility =
|
|
99
|
+
MetadataInspector.getClassMetadata<OperationVisibility>(
|
|
100
|
+
OAI3Keys.VISIBILITY_CLASS_KEY,
|
|
101
|
+
constructor,
|
|
102
|
+
);
|
|
102
103
|
|
|
103
104
|
if (classVisibility) {
|
|
104
105
|
debug(` using class-level @oas.visibility(): '${classVisibility}'`);
|
|
@@ -158,11 +159,12 @@ function resolveControllerSpec(constructor: Function): ControllerSpec {
|
|
|
158
159
|
debug(' using method-level deprecation via @deprecated()');
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
const methodVisibility =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
const methodVisibility =
|
|
163
|
+
MetadataInspector.getMethodMetadata<OperationVisibility>(
|
|
164
|
+
OAI3Keys.VISIBILITY_METHOD_KEY,
|
|
165
|
+
constructor.prototype,
|
|
166
|
+
op,
|
|
167
|
+
);
|
|
166
168
|
|
|
167
169
|
if (methodVisibility) {
|
|
168
170
|
debug(
|
|
@@ -170,11 +172,12 @@ function resolveControllerSpec(constructor: Function): ControllerSpec {
|
|
|
170
172
|
);
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
const methodTags =
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
const methodTags =
|
|
176
|
+
MetadataInspector.getMethodMetadata<TagsDecoratorMetadata>(
|
|
177
|
+
OAI3Keys.TAGS_METHOD_KEY,
|
|
178
|
+
constructor.prototype,
|
|
179
|
+
op,
|
|
180
|
+
);
|
|
178
181
|
|
|
179
182
|
if (methodTags) {
|
|
180
183
|
debug(' using method-level tags via @oas.tags()');
|
|
@@ -196,11 +199,12 @@ function resolveControllerSpec(constructor: Function): ControllerSpec {
|
|
|
196
199
|
|
|
197
200
|
let operationSpec = endpoint.spec;
|
|
198
201
|
|
|
199
|
-
const decoratedResponses =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
const decoratedResponses =
|
|
203
|
+
MetadataInspector.getMethodMetadata<ResponseDecoratorMetadata>(
|
|
204
|
+
OAI3Keys.RESPONSE_METHOD_KEY,
|
|
205
|
+
constructor.prototype,
|
|
206
|
+
op,
|
|
207
|
+
);
|
|
204
208
|
|
|
205
209
|
if (!operationSpec) {
|
|
206
210
|
if (decoratedResponses) {
|
|
@@ -304,11 +308,12 @@ function resolveControllerSpec(constructor: Function): ControllerSpec {
|
|
|
304
308
|
}
|
|
305
309
|
|
|
306
310
|
debug(' processing requestBody for method %s', op);
|
|
307
|
-
let requestBodies =
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
let requestBodies =
|
|
312
|
+
MetadataInspector.getAllParameterMetadata<RequestBodyObject>(
|
|
313
|
+
OAI3Keys.REQUEST_BODY_KEY,
|
|
314
|
+
constructor.prototype,
|
|
315
|
+
op,
|
|
316
|
+
);
|
|
312
317
|
|
|
313
318
|
const bodyIndexes: number[] = [];
|
|
314
319
|
if (requestBodies != null)
|
|
@@ -57,7 +57,7 @@ export function deprecated(isDeprecated = true) {
|
|
|
57
57
|
target: any,
|
|
58
58
|
method?: string,
|
|
59
59
|
// Use `any` to for `TypedPropertyDescriptor`
|
|
60
|
-
// See https://github.com/
|
|
60
|
+
// See https://github.com/loopbackio/loopback-next/pull/2704
|
|
61
61
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
62
|
methodDescriptor?: TypedPropertyDescriptor<any>,
|
|
63
63
|
) {
|
|
@@ -59,7 +59,7 @@ export function tags(...tagNames: string[]) {
|
|
|
59
59
|
target: any,
|
|
60
60
|
method?: string,
|
|
61
61
|
// Use `any` to for `TypedPropertyDescriptor`
|
|
62
|
-
// See https://github.com/
|
|
62
|
+
// See https://github.com/loopbackio/loopback-next/pull/2704
|
|
63
63
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
64
|
methodDescriptor?: TypedPropertyDescriptor<any>,
|
|
65
65
|
) {
|
|
@@ -56,7 +56,7 @@ export function visibility(visibilityType: OperationVisibility) {
|
|
|
56
56
|
target: any,
|
|
57
57
|
method?: string,
|
|
58
58
|
// Use `any` to for `TypedPropertyDescriptor`
|
|
59
|
-
// See https://github.com/
|
|
59
|
+
// See https://github.com/loopbackio/loopback-next/pull/2704
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
61
|
methodDescriptor?: TypedPropertyDescriptor<any>,
|
|
62
62
|
) {
|
|
@@ -121,7 +121,7 @@ export class OASEnhancerService {
|
|
|
121
121
|
*/
|
|
122
122
|
export function mergeOpenAPISpec<
|
|
123
123
|
C extends Partial<OpenApiSpec>,
|
|
124
|
-
P extends Partial<OpenApiSpec
|
|
124
|
+
P extends Partial<OpenApiSpec>,
|
|
125
125
|
>(currentSpec: C, patchSpec: P): C & P {
|
|
126
126
|
const mergedSpec = jsonmergepatch.merge(currentSpec, patchSpec);
|
|
127
127
|
return mergedSpec;
|