@loopback/openapi-v3 1.10.1 → 1.12.0
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/CHANGELOG.md +40 -0
- package/dist/controller-spec.js +62 -31
- package/dist/controller-spec.js.map +1 -1
- package/dist/decorators/api.decorator.js +2 -2
- package/dist/decorators/api.decorator.js.map +1 -1
- package/dist/decorators/operation.decorator.js +2 -2
- package/dist/decorators/operation.decorator.js.map +1 -1
- package/dist/decorators/parameter.decorator.js +5 -4
- package/dist/decorators/parameter.decorator.js.map +1 -1
- package/dist/decorators/request-body.decorator.js +12 -8
- package/dist/decorators/request-body.decorator.js.map +1 -1
- package/dist/enhancers/index.d.ts +3 -0
- package/dist/enhancers/index.js +13 -0
- package/dist/enhancers/index.js.map +1 -0
- package/dist/enhancers/keys.d.ts +6 -0
- package/dist/enhancers/keys.js +12 -0
- package/dist/enhancers/keys.js.map +1 -0
- package/dist/enhancers/spec-enhancer.service.d.ts +73 -0
- package/dist/enhancers/spec-enhancer.service.js +135 -0
- package/dist/enhancers/spec-enhancer.service.js.map +1 -0
- package/dist/enhancers/types.d.ts +18 -0
- package/dist/enhancers/types.js +20 -0
- package/dist/enhancers/types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/json-to-schema.js +16 -11
- package/dist/json-to-schema.js.map +1 -1
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +6 -10
- package/dist/keys.js.map +1 -1
- package/package.json +12 -11
- package/src/controller-spec.ts +53 -21
- package/src/decorators/api.decorator.ts +1 -1
- package/src/decorators/operation.decorator.ts +1 -1
- package/src/decorators/parameter.decorator.ts +2 -2
- package/src/decorators/request-body.decorator.ts +4 -4
- package/src/enhancers/index.ts +8 -0
- package/src/enhancers/keys.ts +14 -0
- package/src/enhancers/spec-enhancer.service.ts +121 -0
- package/src/enhancers/types.ts +30 -0
- package/src/index.ts +1 -0
- package/src/json-to-schema.ts +14 -8
- package/src/keys.ts +1 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,46 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.12.0](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.11.0...@loopback/openapi-v3@1.12.0) (2020-01-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* support x-ts-type in anyOf/allOf/oneOf/not ([28fcc54](https://github.com/strongloop/loopback-next/commit/28fcc545e42d4c5ae88215436b873a78a3fb6c8d))
|
|
12
|
+
* **openapi-v3:** add support for `anyOf` and `oneOf` on the `jsonToSchemaObject` utility ([72ba132](https://github.com/strongloop/loopback-next/commit/72ba1321a85112a3e085d62fe573f60f79d5c64c)), closes [#3524](https://github.com/strongloop/loopback-next/issues/3524)
|
|
13
|
+
* **repository-json-schema:** add title to filter schemas ([6105883](https://github.com/strongloop/loopback-next/commit/6105883967ca5853cc8990f423d9febd1eb07101))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [1.11.0](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.10.3...@loopback/openapi-v3@1.11.0) (2020-01-07)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* openapi spec contributor extension point ([9fee3f3](https://github.com/strongloop/loopback-next/commit/9fee3f342ff76d65d1899ddf1dbf7a257c85ea26))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [1.10.3](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.10.2...@loopback/openapi-v3@1.10.3) (2019-12-09)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @loopback/openapi-v3
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [1.10.2](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.10.1...@loopback/openapi-v3@1.10.2) (2019-11-25)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @loopback/openapi-v3
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
6
46
|
## [1.10.1](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.10.0...@loopback/openapi-v3@1.10.1) (2019-11-12)
|
|
7
47
|
|
|
8
48
|
|
package/dist/controller-spec.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
8
8
|
const repository_json_schema_1 = require("@loopback/repository-json-schema");
|
|
9
|
-
const
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
10
|
const generate_schema_1 = require("./generate-schema");
|
|
11
11
|
const json_to_schema_1 = require("./json-to-schema");
|
|
12
12
|
const keys_1 = require("./keys");
|
|
@@ -18,17 +18,18 @@ exports.TS_TYPE_KEY = 'x-ts-type';
|
|
|
18
18
|
* @param constructor - Controller class
|
|
19
19
|
*/
|
|
20
20
|
function resolveControllerSpec(constructor) {
|
|
21
|
+
var _a, _b;
|
|
21
22
|
debug(`Retrieving OpenAPI specification for controller ${constructor.name}`);
|
|
22
|
-
let spec =
|
|
23
|
+
let spec = core_1.MetadataInspector.getClassMetadata(keys_1.OAI3Keys.CLASS_KEY, constructor);
|
|
23
24
|
if (spec) {
|
|
24
25
|
debug(' using class-level spec defined via @api()', spec);
|
|
25
|
-
spec =
|
|
26
|
+
spec = core_1.DecoratorFactory.cloneDeep(spec);
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
29
|
spec = { paths: {} };
|
|
29
30
|
}
|
|
30
|
-
let endpoints =
|
|
31
|
-
endpoints =
|
|
31
|
+
let endpoints = (_a = core_1.MetadataInspector.getAllMethodMetadata(keys_1.OAI3Keys.METHODS_KEY, constructor.prototype), (_a !== null && _a !== void 0 ? _a : {}));
|
|
32
|
+
endpoints = core_1.DecoratorFactory.cloneDeep(endpoints);
|
|
32
33
|
for (const op in endpoints) {
|
|
33
34
|
debug(' processing method %s', op);
|
|
34
35
|
const endpoint = endpoints[op];
|
|
@@ -60,17 +61,17 @@ function resolveControllerSpec(constructor) {
|
|
|
60
61
|
const responseObject = operationSpec.responses[code];
|
|
61
62
|
if (types_1.isReferenceObject(responseObject))
|
|
62
63
|
continue;
|
|
63
|
-
const content = responseObject.content
|
|
64
|
+
const content = (_b = responseObject.content, (_b !== null && _b !== void 0 ? _b : {}));
|
|
64
65
|
for (const c in content) {
|
|
65
66
|
debug(' processing response code %s with content-type %', code, c);
|
|
66
67
|
processSchemaExtensions(spec, content[c].schema);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
debug(' processing parameters for method %s', op);
|
|
70
|
-
let params =
|
|
71
|
+
let params = core_1.MetadataInspector.getAllParameterMetadata(keys_1.OAI3Keys.PARAMETERS_KEY, constructor.prototype, op);
|
|
71
72
|
debug(' parameters for method %s: %j', op, params);
|
|
72
73
|
if (params != null) {
|
|
73
|
-
params =
|
|
74
|
+
params = core_1.DecoratorFactory.cloneDeep(params);
|
|
74
75
|
/**
|
|
75
76
|
* If a controller method uses dependency injection, the parameters
|
|
76
77
|
* might be sparse. For example,
|
|
@@ -94,7 +95,7 @@ function resolveControllerSpec(constructor) {
|
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
debug(' processing requestBody for method %s', op);
|
|
97
|
-
let requestBodies =
|
|
98
|
+
let requestBodies = core_1.MetadataInspector.getAllParameterMetadata(keys_1.OAI3Keys.REQUEST_BODY_KEY, constructor.prototype, op);
|
|
98
99
|
if (requestBodies != null)
|
|
99
100
|
requestBodies = requestBodies.filter(p => p != null);
|
|
100
101
|
let requestBody;
|
|
@@ -103,8 +104,10 @@ function resolveControllerSpec(constructor) {
|
|
|
103
104
|
throw new Error('An operation should only have one parameter decorated by @requestBody');
|
|
104
105
|
requestBody = requestBodies[0];
|
|
105
106
|
debug(' requestBody for method %s: %j', op, requestBody);
|
|
107
|
+
/* istanbul ignore else */
|
|
106
108
|
if (requestBody) {
|
|
107
109
|
operationSpec.requestBody = requestBody;
|
|
110
|
+
/* istanbul ignore else */
|
|
108
111
|
const content = requestBody.content || {};
|
|
109
112
|
for (const mediaType in content) {
|
|
110
113
|
processSchemaExtensions(spec, content[mediaType].schema);
|
|
@@ -133,9 +136,9 @@ function resolveControllerSpec(constructor) {
|
|
|
133
136
|
debug(` adding ${endpointName}`, operationSpec);
|
|
134
137
|
spec.paths[path][verb] = operationSpec;
|
|
135
138
|
debug(` inferring schema object for method %s`, op);
|
|
136
|
-
const opMetadata =
|
|
139
|
+
const opMetadata = core_1.MetadataInspector.getDesignTypeForMethod(constructor.prototype, op);
|
|
137
140
|
const paramTypes = opMetadata.parameterTypes;
|
|
138
|
-
const isComplexType = (ctor) => !
|
|
141
|
+
const isComplexType = (ctor) => !lodash_1.includes([String, Number, Boolean, Array, Object], ctor);
|
|
139
142
|
for (const p of paramTypes) {
|
|
140
143
|
if (isComplexType(p)) {
|
|
141
144
|
generateOpenAPISchema(spec, p);
|
|
@@ -144,6 +147,7 @@ function resolveControllerSpec(constructor) {
|
|
|
144
147
|
}
|
|
145
148
|
return spec;
|
|
146
149
|
}
|
|
150
|
+
const SCHEMA_ARR_KEYS = ['allOf', 'anyOf', 'oneOf'];
|
|
147
151
|
/**
|
|
148
152
|
* Resolve the x-ts-type in the schema object
|
|
149
153
|
* @param spec - Controller spec
|
|
@@ -155,25 +159,52 @@ function processSchemaExtensions(spec, schema) {
|
|
|
155
159
|
return;
|
|
156
160
|
assignRelatedSchemas(spec, schema.definitions);
|
|
157
161
|
delete schema.definitions;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
generateOpenAPISchema(spec, tsType);
|
|
166
|
-
// We don't want a Function type in the final spec.
|
|
167
|
-
delete schema[exports.TS_TYPE_KEY];
|
|
168
|
-
return;
|
|
162
|
+
/**
|
|
163
|
+
* check if we have been provided a `not`
|
|
164
|
+
* `not` is valid in many cases- here we're checking for
|
|
165
|
+
* `not: { schema: {'x-ts-type': SomeModel }}
|
|
166
|
+
*/
|
|
167
|
+
if (schema.not) {
|
|
168
|
+
processSchemaExtensions(spec, schema.not);
|
|
169
169
|
}
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
/**
|
|
171
|
+
* check for schema.allOf, schema.oneOf, schema.anyOf arrays first.
|
|
172
|
+
* You cannot provide BOTH a defnintion AND one of these keywords.
|
|
173
|
+
*/
|
|
174
|
+
/* istanbul ignore else */
|
|
175
|
+
const hasOwn = (prop) => { var _a; return (_a = schema) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(prop); };
|
|
176
|
+
if (SCHEMA_ARR_KEYS.some(k => hasOwn(k))) {
|
|
177
|
+
SCHEMA_ARR_KEYS.forEach((k) => {
|
|
178
|
+
var _a;
|
|
179
|
+
/* istanbul ignore else */
|
|
180
|
+
if (((_a = schema) === null || _a === void 0 ? void 0 : _a[k]) && Array.isArray(schema[k])) {
|
|
181
|
+
schema[k].forEach((r) => {
|
|
182
|
+
processSchemaExtensions(spec, r);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
172
186
|
}
|
|
173
|
-
else
|
|
174
|
-
if (schema
|
|
175
|
-
|
|
176
|
-
|
|
187
|
+
else {
|
|
188
|
+
if (types_1.isReferenceObject(schema))
|
|
189
|
+
return;
|
|
190
|
+
const tsType = schema[exports.TS_TYPE_KEY];
|
|
191
|
+
debug(' %s => %o', exports.TS_TYPE_KEY, tsType);
|
|
192
|
+
if (tsType) {
|
|
193
|
+
schema = generate_schema_1.resolveSchema(tsType, schema);
|
|
194
|
+
if (schema.$ref)
|
|
195
|
+
generateOpenAPISchema(spec, tsType);
|
|
196
|
+
// We don't want a Function type in the final spec.
|
|
197
|
+
delete schema[exports.TS_TYPE_KEY];
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (schema.type === 'array') {
|
|
201
|
+
processSchemaExtensions(spec, schema.items);
|
|
202
|
+
}
|
|
203
|
+
else if (schema.type === 'object') {
|
|
204
|
+
if (schema.properties) {
|
|
205
|
+
for (const p in schema.properties) {
|
|
206
|
+
processSchemaExtensions(spec, schema.properties[p]);
|
|
207
|
+
}
|
|
177
208
|
}
|
|
178
209
|
}
|
|
179
210
|
}
|
|
@@ -232,10 +263,10 @@ function assignRelatedSchemas(spec, definitions) {
|
|
|
232
263
|
* @param constructor - Controller class
|
|
233
264
|
*/
|
|
234
265
|
function getControllerSpec(constructor) {
|
|
235
|
-
let spec =
|
|
266
|
+
let spec = core_1.MetadataInspector.getClassMetadata(keys_1.OAI3Keys.CONTROLLER_SPEC_KEY, constructor, { ownMetadataOnly: true });
|
|
236
267
|
if (!spec) {
|
|
237
268
|
spec = resolveControllerSpec(constructor);
|
|
238
|
-
|
|
269
|
+
core_1.MetadataInspector.defineMetadata(keys_1.OAI3Keys.CONTROLLER_SPEC_KEY.key, spec, constructor);
|
|
239
270
|
}
|
|
240
271
|
return spec;
|
|
241
272
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-spec.js","sourceRoot":"","sources":["../src/controller-spec.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE
|
|
1
|
+
{"version":3,"file":"controller-spec.js","sourceRoot":"","sources":["../src/controller-spec.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAAmE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AI,EAAC,CACxB,CAAC;IACF,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC1C,wBAAiB,CAAC,cAAc,CAC9B,eAAQ,CAAC,mBAAmB,CAAC,GAAG,EAChC,IAAI,EACJ,WAAW,CACZ,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAfD,8CAeC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,iBAAiB,CAC/B,SAAoC,EACpC,OAA8B;IAE9B,MAAM,UAAU,GAAG,yCAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,OAAO,mCAAkB,CAAC,UAAU,CAAc,CAAC;AACrD,CAAC;AAND,8CAMC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
8
8
|
const keys_1 = require("../keys");
|
|
9
9
|
/**
|
|
10
10
|
* Decorate the given Controller constructor with metadata describing
|
|
@@ -26,7 +26,7 @@ const keys_1 = require("../keys");
|
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
28
|
function api(spec) {
|
|
29
|
-
return
|
|
29
|
+
return core_1.ClassDecoratorFactory.createDecorator(keys_1.OAI3Keys.CLASS_KEY, spec, { decoratorName: '@api' });
|
|
30
30
|
}
|
|
31
31
|
exports.api = api;
|
|
32
32
|
//# sourceMappingURL=api.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.decorator.js","sourceRoot":"","sources":["../../src/decorators/api.decorator.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE
|
|
1
|
+
{"version":3,"file":"api.decorator.js","sourceRoot":"","sources":["../../src/decorators/api.decorator.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAAqD;AAErD,kCAAiC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,GAAG,CAAC,IAAoB;IACtC,OAAO,4BAAqB,CAAC,eAAe,CAC1C,eAAQ,CAAC,SAAS,EAClB,IAAI,EACJ,EAAC,aAAa,EAAE,MAAM,EAAC,CACxB,CAAC;AACJ,CAAC;AAND,kBAMC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
8
8
|
const keys_1 = require("../keys");
|
|
9
9
|
/**
|
|
10
10
|
* Expose a Controller method as a REST API operation
|
|
@@ -75,7 +75,7 @@ exports.del = del;
|
|
|
75
75
|
* of this operation.
|
|
76
76
|
*/
|
|
77
77
|
function operation(verb, path, spec) {
|
|
78
|
-
return
|
|
78
|
+
return core_1.MethodDecoratorFactory.createDecorator(keys_1.OAI3Keys.METHODS_KEY, {
|
|
79
79
|
verb,
|
|
80
80
|
path,
|
|
81
81
|
spec,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.decorator.js","sourceRoot":"","sources":["../../src/decorators/operation.decorator.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE
|
|
1
|
+
{"version":3,"file":"operation.decorator.js","sourceRoot":"","sources":["../../src/decorators/operation.decorator.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAAsD;AAEtD,kCAAiC;AAGjC;;;;;;;GAOG;AACH,SAAgB,GAAG,CAAC,IAAY,EAAE,IAAsB;IACtD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAFD,kBAEC;AAED;;;;;;;GAOG;AACH,SAAgB,IAAI,CAAC,IAAY,EAAE,IAAsB;IACvD,OAAO,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC;AAED;;;;;;;GAOG;AACH,SAAgB,GAAG,CAAC,IAAY,EAAE,IAAsB;IACtD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAFD,kBAEC;AAED;;;;;;;GAOG;AACH,SAAgB,KAAK,CAAC,IAAY,EAAE,IAAsB;IACxD,OAAO,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAFD,sBAEC;AAED;;;;;;;GAOG;AACH,SAAgB,GAAG,CAAC,IAAY,EAAE,IAAsB;IACtD,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAFD,kBAEC;AAED;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,IAAY,EAAE,IAAsB;IAC1E,OAAO,6BAAsB,CAAC,eAAe,CAC3C,eAAQ,CAAC,WAAW,EACpB;QACE,IAAI;QACJ,IAAI;QACJ,IAAI;KACL,EACD,EAAC,aAAa,EAAE,YAAY,EAAC,CAC9B,CAAC;AACJ,CAAC;AAVD,8BAUC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
8
8
|
const generate_schema_1 = require("../generate-schema");
|
|
9
9
|
const keys_1 = require("../keys");
|
|
10
10
|
const types_1 = require("../types");
|
|
@@ -28,10 +28,11 @@ const types_1 = require("../types");
|
|
|
28
28
|
*/
|
|
29
29
|
function param(paramSpec) {
|
|
30
30
|
return function (target, member, index) {
|
|
31
|
+
var _a;
|
|
31
32
|
paramSpec = paramSpec || {};
|
|
32
33
|
// Get the design time method parameter metadata
|
|
33
|
-
const methodSig =
|
|
34
|
-
const paramTypes = (methodSig
|
|
34
|
+
const methodSig = core_1.MetadataInspector.getDesignTypeForMethod(target, member);
|
|
35
|
+
const paramTypes = ((_a = methodSig) === null || _a === void 0 ? void 0 : _a.parameterTypes) || [];
|
|
35
36
|
// Map design-time parameter type to the OpenAPI param type
|
|
36
37
|
const paramType = paramTypes[index];
|
|
37
38
|
if (paramType) {
|
|
@@ -52,7 +53,7 @@ function param(paramSpec) {
|
|
|
52
53
|
throw new Error(`The parameter type is set to 'array' but the JavaScript type is ${paramType.name}`);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
core_1.ParameterDecoratorFactory.createDecorator(keys_1.OAI3Keys.PARAMETERS_KEY, paramSpec, { decoratorName: '@param' })(target, member, index);
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
exports.param = param;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter.decorator.js","sourceRoot":"","sources":["../../src/decorators/parameter.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE
|
|
1
|
+
{"version":3,"file":"parameter.decorator.js","sourceRoot":"","sources":["../../src/decorators/parameter.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAA4E;AAC5E,wDAAiD;AACjD,kCAAiC;AACjC,oCAMkB;AAElB;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,KAAK,CAAC,SAA0B;IAC9C,OAAO,UAAS,MAAc,EAAE,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i-v3
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
10
|
+
const core_1 = require("@loopback/core");
|
|
11
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
12
|
const util_1 = require("util");
|
|
10
13
|
const generate_schema_1 = require("../generate-schema");
|
|
11
14
|
const keys_1 = require("../keys");
|
|
@@ -77,24 +80,25 @@ exports.REQUEST_BODY_INDEX = 'x-parameter-index';
|
|
|
77
80
|
*/
|
|
78
81
|
function requestBody(requestBodySpec) {
|
|
79
82
|
return function (target, member, index) {
|
|
83
|
+
var _a;
|
|
80
84
|
debug('@requestBody() on %s.%s', target.constructor.name, member);
|
|
81
85
|
debug(' parameter index: %s', index);
|
|
82
86
|
/* istanbul ignore if */
|
|
83
87
|
if (debug.enabled)
|
|
84
88
|
debug(' options: %s', util_1.inspect(requestBodySpec, { depth: null }));
|
|
85
89
|
// Use 'application/json' as default content if `requestBody` is undefined
|
|
86
|
-
requestBodySpec = requestBodySpec
|
|
87
|
-
if (
|
|
90
|
+
requestBodySpec = (requestBodySpec !== null && requestBodySpec !== void 0 ? requestBodySpec : { content: {} });
|
|
91
|
+
if (lodash_1.default.isEmpty(requestBodySpec.content))
|
|
88
92
|
requestBodySpec.content = { 'application/json': {} };
|
|
89
93
|
// Get the design time method parameter metadata
|
|
90
|
-
const methodSig =
|
|
91
|
-
const paramTypes = (methodSig
|
|
94
|
+
const methodSig = core_1.MetadataInspector.getDesignTypeForMethod(target, member);
|
|
95
|
+
const paramTypes = ((_a = methodSig) === null || _a === void 0 ? void 0 : _a.parameterTypes) || [];
|
|
92
96
|
const paramType = paramTypes[index];
|
|
93
97
|
const schema = generate_schema_1.resolveSchema(paramType);
|
|
94
98
|
/* istanbul ignore if */
|
|
95
99
|
if (debug.enabled)
|
|
96
100
|
debug(' inferred schema: %s', util_1.inspect(schema, { depth: null }));
|
|
97
|
-
requestBodySpec.content =
|
|
101
|
+
requestBodySpec.content = lodash_1.default.mapValues(requestBodySpec.content, c => {
|
|
98
102
|
if (!c.schema) {
|
|
99
103
|
c.schema = schema;
|
|
100
104
|
}
|
|
@@ -108,7 +112,7 @@ function requestBody(requestBodySpec) {
|
|
|
108
112
|
/* istanbul ignore if */
|
|
109
113
|
if (debug.enabled)
|
|
110
114
|
debug(' final spec: ', util_1.inspect(requestBodySpec, { depth: null }));
|
|
111
|
-
|
|
115
|
+
core_1.ParameterDecoratorFactory.createDecorator(keys_1.OAI3Keys.REQUEST_BODY_KEY, requestBodySpec, { decoratorName: '@requestBody' })(target, member, index);
|
|
112
116
|
};
|
|
113
117
|
}
|
|
114
118
|
exports.requestBody = requestBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body.decorator.js","sourceRoot":"","sources":["../../src/decorators/request-body.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"request-body.decorator.js","sourceRoot":"","sources":["../../src/decorators/request-body.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,yCAA4E;AAC5E,oDAAuB;AACvB,+BAA6B;AAC7B,wDAAiD;AACjD,kCAAiC;AAGjC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wCAAwC,CAAC,CAAC;AAC5D,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,SAAgB,WAAW,CAAC,eAA4C;IACtE,OAA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DAAsD;QACtD,oEAAoE;QACpE,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,eAAe,CAAC,0BAAkB,CAAC,GAAG,KAAK,CAAC;SAC7C;QAED,wBAAwB;QACxB,IAAI,KAAK,CAAC,OAAO;YACf,KAAK,CAAC,gBAAgB,EAAE,cAAO,CAAC,eAAe,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;QACnE,gCAAyB,CAAC,eAAe,CACvC,eAAQ,CAAC,gBAAgB,EACzB,eAAoC,EACpC,EAAC,aAAa,EAAE,cAAc,EAAC,CAChC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AA7CD,kCA6CC;AAED,WAAiB,WAAW;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;IACU,iBAAK,GAAG,UACnB,QAAwC,EACxC,UAAuD;QAEvD,OAAO,WAAW,iCACb,UAAU,KACb,OAAO,EAAE;gBACP,kBAAkB,EAAE;oBAClB,MAAM,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAC;iBACzC;aACF,IACD,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,EAjCgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAiC3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2019. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/openapi-v3
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
function __export(m) {
|
|
7
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
__export(require("./keys"));
|
|
11
|
+
__export(require("./spec-enhancer.service"));
|
|
12
|
+
__export(require("./types"));
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enhancers/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,4BAAuB;AACvB,6CAAwC;AACxC,6BAAwB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2019. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/openapi-v3
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
8
|
+
/**
|
|
9
|
+
* Strongly-typed binding key for SpecService
|
|
10
|
+
*/
|
|
11
|
+
exports.OAS_ENHANCER_SERVICE = core_1.BindingKey.create('services.SpecService');
|
|
12
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/enhancers/keys.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAA0C;AAG1C;;GAEG;AACU,QAAA,oBAAoB,GAAG,iBAAU,CAAC,MAAM,CACnD,sBAAsB,CACvB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Getter } from '@loopback/core';
|
|
2
|
+
import { OpenApiSpec } from '../types';
|
|
3
|
+
import { OASEnhancer } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the OpenAPI Spec enhancer extension point
|
|
6
|
+
*/
|
|
7
|
+
export interface OASEnhancerServiceOptions {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* An extension point for OpenAPI Spec enhancement
|
|
11
|
+
* This service is used for enhancing an OpenAPI spec by loading and applying one or more
|
|
12
|
+
* registered enhancers.
|
|
13
|
+
*
|
|
14
|
+
* A typical use of it would be generating the OpenAPI spec for the endpoints on a server
|
|
15
|
+
* in the `@loopback/rest` module.
|
|
16
|
+
*/
|
|
17
|
+
export declare class OASEnhancerService {
|
|
18
|
+
/**
|
|
19
|
+
* Inject a getter function to fetch spec enhancers
|
|
20
|
+
*/
|
|
21
|
+
private getEnhancers;
|
|
22
|
+
/**
|
|
23
|
+
* An extension point should be able to receive its options via dependency
|
|
24
|
+
* injection.
|
|
25
|
+
*/
|
|
26
|
+
readonly options?: OASEnhancerServiceOptions | undefined;
|
|
27
|
+
constructor(
|
|
28
|
+
/**
|
|
29
|
+
* Inject a getter function to fetch spec enhancers
|
|
30
|
+
*/
|
|
31
|
+
getEnhancers: Getter<OASEnhancer[]>,
|
|
32
|
+
/**
|
|
33
|
+
* An extension point should be able to receive its options via dependency
|
|
34
|
+
* injection.
|
|
35
|
+
*/
|
|
36
|
+
options?: OASEnhancerServiceOptions | undefined);
|
|
37
|
+
private _spec;
|
|
38
|
+
/**
|
|
39
|
+
* Getter for `_spec`
|
|
40
|
+
*/
|
|
41
|
+
get spec(): OpenApiSpec;
|
|
42
|
+
/**
|
|
43
|
+
* Setter for `_spec`
|
|
44
|
+
*/
|
|
45
|
+
set spec(value: OpenApiSpec);
|
|
46
|
+
/**
|
|
47
|
+
* Find an enhancer by its name
|
|
48
|
+
* @param name The name of the enhancer you want to find
|
|
49
|
+
*/
|
|
50
|
+
getEnhancerByName(name: string): Promise<OASEnhancer | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Apply a given enhancer's merge function. Return the latest _spec.
|
|
53
|
+
* @param name The name of the enhancer you want to apply
|
|
54
|
+
*/
|
|
55
|
+
applyEnhancerByName(name: string): Promise<OpenApiSpec>;
|
|
56
|
+
/**
|
|
57
|
+
* Generate OpenAPI spec by applying ALL registered enhancers
|
|
58
|
+
* TBD: load enhancers by group names
|
|
59
|
+
*/
|
|
60
|
+
applyAllEnhancers(options?: {}): Promise<OpenApiSpec>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The default merge function to patch the current OpenAPI spec.
|
|
64
|
+
* It leverages module `json-merge-patch`'s merge API to merge two json objects.
|
|
65
|
+
* It returns a new merged object without modifying the original one.
|
|
66
|
+
*
|
|
67
|
+
* A list of merging rules can be found in test file:
|
|
68
|
+
* https://github.com/pierreinglebert/json-merge-patch/blob/master/test/lib/merge.js
|
|
69
|
+
*
|
|
70
|
+
* @param currentSpec The original spec
|
|
71
|
+
* @param patchSpec The patch spec to be merged into the original spec
|
|
72
|
+
*/
|
|
73
|
+
export declare function mergeOpenAPISpec(currentSpec: Partial<OpenApiSpec>, patchSpec: Partial<OpenApiSpec>): any;
|