@loopback/rest 5.0.1 → 5.2.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 +47 -0
- package/dist/body-parsers/body-parser.d.ts +1 -1
- package/dist/body-parsers/body-parser.helpers.js +1 -1
- package/dist/body-parsers/body-parser.js +112 -115
- package/dist/body-parsers/body-parser.js.map +1 -1
- package/dist/body-parsers/body-parser.json.js +24 -27
- package/dist/body-parsers/body-parser.json.js.map +1 -1
- package/dist/body-parsers/body-parser.raw.js +19 -22
- package/dist/body-parsers/body-parser.raw.js.map +1 -1
- package/dist/body-parsers/body-parser.text.js +21 -24
- package/dist/body-parsers/body-parser.text.js.map +1 -1
- package/dist/body-parsers/body-parser.urlencoded.js +19 -22
- package/dist/body-parsers/body-parser.urlencoded.js.map +1 -1
- package/dist/body-parsers/index.js +1 -1
- package/dist/body-parsers/index.js.map +1 -1
- package/dist/coercion/coerce-parameter.d.ts +3 -1
- package/dist/coercion/coerce-parameter.js +28 -12
- package/dist/coercion/coerce-parameter.js.map +1 -1
- package/dist/coercion/validator.js +1 -1
- package/dist/http-handler.d.ts +1 -1
- package/dist/http-handler.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +33 -34
- package/dist/keys.js.map +1 -1
- package/dist/parser.js +1 -1
- package/dist/parser.js.map +1 -1
- package/dist/providers/find-route.provider.d.ts +1 -1
- package/dist/providers/find-route.provider.js +21 -24
- package/dist/providers/find-route.provider.js.map +1 -1
- package/dist/providers/invoke-method.provider.d.ts +1 -1
- package/dist/providers/invoke-method.provider.js +16 -19
- package/dist/providers/invoke-method.provider.js.map +1 -1
- package/dist/providers/log-error.provider.d.ts +1 -1
- package/dist/providers/parse-params.provider.d.ts +1 -1
- package/dist/providers/parse-params.provider.js +20 -23
- package/dist/providers/parse-params.provider.js.map +1 -1
- package/dist/providers/reject.provider.d.ts +1 -1
- package/dist/providers/reject.provider.js +25 -28
- package/dist/providers/reject.provider.js.map +1 -1
- package/dist/providers/send.provider.d.ts +1 -1
- package/dist/request-context.d.ts +1 -1
- package/dist/rest.application.d.ts +15 -2
- package/dist/rest.application.js +14 -1
- package/dist/rest.application.js.map +1 -1
- package/dist/rest.component.d.ts +1 -1
- package/dist/rest.component.js +46 -49
- package/dist/rest.component.js.map +1 -1
- package/dist/rest.server.d.ts +15 -2
- package/dist/rest.server.js +615 -588
- package/dist/rest.server.js.map +1 -1
- package/dist/router/base-route.d.ts +1 -1
- package/dist/router/controller-route.d.ts +1 -1
- package/dist/router/controller-route.js +3 -4
- package/dist/router/controller-route.js.map +1 -1
- package/dist/router/external-express-routes.js +1 -1
- package/dist/router/external-express-routes.js.map +1 -1
- package/dist/router/handler-route.d.ts +1 -1
- package/dist/router/handler-route.js +2 -2
- package/dist/router/handler-route.js.map +1 -1
- package/dist/router/redirect-route.js +2 -2
- package/dist/router/redirect-route.js.map +1 -1
- package/dist/router/regexp-router.js +55 -58
- package/dist/router/regexp-router.js.map +1 -1
- package/dist/router/route-entry.d.ts +1 -1
- package/dist/router/trie-router.js +32 -35
- package/dist/router/trie-router.js.map +1 -1
- package/dist/sequence.d.ts +1 -1
- package/dist/sequence.js +74 -77
- package/dist/sequence.js.map +1 -1
- package/dist/spec-enhancers/consolidate.spec-enhancer.js +89 -92
- package/dist/spec-enhancers/consolidate.spec-enhancer.js.map +1 -1
- package/dist/spec-enhancers/info.spec-enhancer.js +63 -67
- package/dist/spec-enhancers/info.spec-enhancer.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/validation/ajv-factory.provider.js +63 -66
- package/dist/validation/ajv-factory.provider.js.map +1 -1
- package/dist/validation/request-body.validator.d.ts +10 -2
- package/dist/validation/request-body.validator.js +25 -9
- package/dist/validation/request-body.validator.js.map +1 -1
- package/package.json +25 -23
- package/src/body-parsers/body-parser.helpers.ts +1 -1
- package/src/body-parsers/body-parser.json.ts +1 -1
- package/src/body-parsers/body-parser.raw.ts +1 -1
- package/src/body-parsers/body-parser.text.ts +1 -1
- package/src/body-parsers/body-parser.ts +1 -1
- package/src/body-parsers/body-parser.urlencoded.ts +1 -1
- package/src/body-parsers/index.ts +1 -1
- package/src/coercion/coerce-parameter.ts +55 -15
- package/src/coercion/validator.ts +1 -1
- package/src/http-handler.ts +2 -2
- package/src/index.ts +6 -0
- package/src/keys.ts +1 -2
- package/src/parser.ts +1 -1
- package/src/providers/find-route.provider.ts +1 -1
- package/src/providers/invoke-method.provider.ts +1 -1
- package/src/providers/log-error.provider.ts +1 -1
- package/src/providers/parse-params.provider.ts +1 -1
- package/src/providers/reject.provider.ts +1 -1
- package/src/providers/send.provider.ts +1 -1
- package/src/request-context.ts +1 -1
- package/src/rest.application.ts +19 -3
- package/src/rest.component.ts +1 -1
- package/src/rest.server.ts +35 -3
- package/src/router/base-route.ts +1 -1
- package/src/router/controller-route.ts +2 -2
- package/src/router/external-express-routes.ts +2 -2
- package/src/router/handler-route.ts +1 -1
- package/src/router/redirect-route.ts +1 -2
- package/src/router/regexp-router.ts +1 -1
- package/src/router/route-entry.ts +1 -1
- package/src/router/trie-router.ts +2 -2
- package/src/sequence.ts +1 -1
- package/src/spec-enhancers/info.spec-enhancer.ts +3 -2
- package/src/types.ts +11 -0
- package/src/validation/request-body.validator.ts +35 -12
package/dist/sequence.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.DefaultSequence = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
const debug = require('debug')('loopback:rest:sequence');
|
|
10
|
-
const
|
|
10
|
+
const core_1 = require("@loopback/core");
|
|
11
11
|
const keys_1 = require("./keys");
|
|
12
12
|
const SequenceActions = keys_1.RestBindings.SequenceActions;
|
|
13
13
|
/**
|
|
@@ -28,85 +28,82 @@ const SequenceActions = keys_1.RestBindings.SequenceActions;
|
|
|
28
28
|
* app.bind(CoreBindings.SEQUENCE).toClass(MySequence);
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
let DefaultSequence =
|
|
32
|
-
|
|
31
|
+
let DefaultSequence = class DefaultSequence {
|
|
32
|
+
/**
|
|
33
|
+
* Constructor: Injects findRoute, invokeMethod & logError
|
|
34
|
+
* methods as promises.
|
|
35
|
+
*
|
|
36
|
+
* @param findRoute - Finds the appropriate controller method,
|
|
37
|
+
* spec and args for invocation (injected via SequenceActions.FIND_ROUTE).
|
|
38
|
+
* @param parseParams - The parameter parsing function (injected
|
|
39
|
+
* via SequenceActions.PARSE_PARAMS).
|
|
40
|
+
* @param invoke - Invokes the method specified by the route
|
|
41
|
+
* (injected via SequenceActions.INVOKE_METHOD).
|
|
42
|
+
* @param send - The action to merge the invoke result with the response
|
|
43
|
+
* (injected via SequenceActions.SEND)
|
|
44
|
+
* @param reject - The action to take if the invoke returns a rejected
|
|
45
|
+
* promise result (injected via SequenceActions.REJECT).
|
|
46
|
+
*/
|
|
47
|
+
constructor(findRoute, parseParams, invoke, send, reject) {
|
|
48
|
+
this.findRoute = findRoute;
|
|
49
|
+
this.parseParams = parseParams;
|
|
50
|
+
this.invoke = invoke;
|
|
51
|
+
this.send = send;
|
|
52
|
+
this.reject = reject;
|
|
33
53
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @param findRoute - Finds the appropriate controller method,
|
|
38
|
-
* spec and args for invocation (injected via SequenceActions.FIND_ROUTE).
|
|
39
|
-
* @param parseParams - The parameter parsing function (injected
|
|
40
|
-
* via SequenceActions.PARSE_PARAMS).
|
|
41
|
-
* @param invoke - Invokes the method specified by the route
|
|
42
|
-
* (injected via SequenceActions.INVOKE_METHOD).
|
|
43
|
-
* @param send - The action to merge the invoke result with the response
|
|
44
|
-
* (injected via SequenceActions.SEND)
|
|
45
|
-
* @param reject - The action to take if the invoke returns a rejected
|
|
46
|
-
* promise result (injected via SequenceActions.REJECT).
|
|
54
|
+
* Optional invoker for registered middleware in a chain.
|
|
55
|
+
* To be injected via SequenceActions.INVOKE_MIDDLEWARE.
|
|
47
56
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* per-request IoC container and more.
|
|
76
|
-
*/
|
|
77
|
-
async handle(context) {
|
|
78
|
-
try {
|
|
79
|
-
const { request, response } = context;
|
|
80
|
-
// Invoke registered Express middleware
|
|
81
|
-
const finished = await this.invokeMiddleware(context);
|
|
82
|
-
if (finished) {
|
|
83
|
-
// The response been produced by the middleware chain
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const route = this.findRoute(request);
|
|
87
|
-
const args = await this.parseParams(request, route);
|
|
88
|
-
const result = await this.invoke(route, args);
|
|
89
|
-
debug('%s result -', route.describe(), result);
|
|
90
|
-
this.send(response, result);
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
this.reject(context, error);
|
|
57
|
+
this.invokeMiddleware = () => false;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Runs the default sequence. Given a handler context (request and response),
|
|
61
|
+
* running the sequence will produce a response or an error.
|
|
62
|
+
*
|
|
63
|
+
* Default sequence executes these steps
|
|
64
|
+
* - Executes middleware for CORS, OpenAPI spec endpoints
|
|
65
|
+
* - Finds the appropriate controller method, swagger spec
|
|
66
|
+
* and args for invocation
|
|
67
|
+
* - Parses HTTP request to get API argument list
|
|
68
|
+
* - Invokes the API which is defined in the Application Controller
|
|
69
|
+
* - Writes the result from API into the HTTP response
|
|
70
|
+
* - Error is caught and logged using 'logError' if any of the above steps
|
|
71
|
+
* in the sequence fails with an error.
|
|
72
|
+
*
|
|
73
|
+
* @param context - The request context: HTTP request and response objects,
|
|
74
|
+
* per-request IoC container and more.
|
|
75
|
+
*/
|
|
76
|
+
async handle(context) {
|
|
77
|
+
try {
|
|
78
|
+
const { request, response } = context;
|
|
79
|
+
// Invoke registered Express middleware
|
|
80
|
+
const finished = await this.invokeMiddleware(context);
|
|
81
|
+
if (finished) {
|
|
82
|
+
// The response been produced by the middleware chain
|
|
83
|
+
return;
|
|
94
84
|
}
|
|
85
|
+
const route = this.findRoute(request);
|
|
86
|
+
const args = await this.parseParams(request, route);
|
|
87
|
+
const result = await this.invoke(route, args);
|
|
88
|
+
debug('%s result -', route.describe(), result);
|
|
89
|
+
this.send(response, result);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this.reject(context, error);
|
|
95
93
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
})();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
tslib_1.__decorate([
|
|
97
|
+
core_1.inject(SequenceActions.INVOKE_MIDDLEWARE, { optional: true }),
|
|
98
|
+
tslib_1.__metadata("design:type", Function)
|
|
99
|
+
], DefaultSequence.prototype, "invokeMiddleware", void 0);
|
|
100
|
+
DefaultSequence = tslib_1.__decorate([
|
|
101
|
+
tslib_1.__param(0, core_1.inject(SequenceActions.FIND_ROUTE)),
|
|
102
|
+
tslib_1.__param(1, core_1.inject(SequenceActions.PARSE_PARAMS)),
|
|
103
|
+
tslib_1.__param(2, core_1.inject(SequenceActions.INVOKE_METHOD)),
|
|
104
|
+
tslib_1.__param(3, core_1.inject(SequenceActions.SEND)),
|
|
105
|
+
tslib_1.__param(4, core_1.inject(SequenceActions.REJECT)),
|
|
106
|
+
tslib_1.__metadata("design:paramtypes", [Function, Function, Function, Function, Function])
|
|
107
|
+
], DefaultSequence);
|
|
111
108
|
exports.DefaultSequence = DefaultSequence;
|
|
112
109
|
//# sourceMappingURL=sequence.js.map
|
package/dist/sequence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,CAAC;AACzD
|
|
1
|
+
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,CAAC;AACzD,yCAAsD;AAEtD,iCAAoC;AAIpC,MAAM,eAAe,GAAG,mBAAY,CAAC,eAAe,CAAC;AAyBrD;;;;;;;;;;;;;;;;;GAiBG;AACH,IAAa,eAAe,GAA5B,MAAa,eAAe;IAQ1B;;;;;;;;;;;;;;OAcG;IACH,YACgD,SAAoB,EAClB,WAAwB,EACvB,MAAoB,EAChC,IAAU,EACR,MAAc;QAJP,cAAS,GAAT,SAAS,CAAW;QAClB,gBAAW,GAAX,WAAW,CAAa;QACvB,WAAM,GAAN,MAAM,CAAc;QAChC,SAAI,GAAJ,IAAI,CAAM;QACR,WAAM,GAAN,MAAM,CAAQ;QA3BvD;;;WAGG;QAEO,qBAAgB,GAAqB,GAAG,EAAE,CAAC,KAAK,CAAC;IAuBxD,CAAC;IAEJ;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,MAAM,CAAC,OAAu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schemas to avoid naming collisions, the description field
|
|
46
46
|
* is ignored.
|
|
47
47
|
*/
|
|
48
|
-
let ConsolidationEnhancer =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
let ConsolidationEnhancer = class ConsolidationEnhancer {
|
|
49
|
+
constructor(config) {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
this.config = config;
|
|
52
|
+
this.name = 'consolidate';
|
|
53
|
+
this.disabled = ((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.rest) === null || _b === void 0 ? void 0 : _b.openApiSpec) === null || _c === void 0 ? void 0 : _c.consolidate) === false;
|
|
54
|
+
}
|
|
55
|
+
modifySpec(spec) {
|
|
56
|
+
return !this.disabled ? this.consolidateSchemaObjects(spec) : spec;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Recursively search OpenApiSpec PathsObject for SchemaObjects with title
|
|
60
|
+
* property. Moves reusable schema bodies to #/components/schemas and replace
|
|
61
|
+
* with json pointer. It handles title collisions with schema body comparision.
|
|
62
|
+
*/
|
|
63
|
+
consolidateSchemaObjects(spec) {
|
|
64
|
+
// use 'paths' as crawl root
|
|
65
|
+
this.recursiveWalk(spec.paths, ['paths'], spec);
|
|
66
|
+
return spec;
|
|
67
|
+
}
|
|
68
|
+
recursiveWalk(rootSchema, parentPath, spec) {
|
|
69
|
+
if (this.isTraversable(rootSchema)) {
|
|
70
|
+
Object.entries(rootSchema).forEach(([key, subSchema]) => {
|
|
71
|
+
if (subSchema) {
|
|
72
|
+
this.recursiveWalk(subSchema, parentPath.concat(key), spec);
|
|
73
|
+
this.processSchema(subSchema, parentPath.concat(key), spec);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
68
76
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Carry out schema consolidation after tree traversal. If 'title' property
|
|
80
|
+
* set then we consider current schema for consolidation. SchemaObjects with
|
|
81
|
+
* properties (and title set) are moved to #/components/schemas/<title> and
|
|
82
|
+
* replaced with ReferenceObject.
|
|
83
|
+
*
|
|
84
|
+
* Features:
|
|
85
|
+
* - name collision protection
|
|
86
|
+
*
|
|
87
|
+
* @param schema - current schema element to process
|
|
88
|
+
* @param parentPath - path object to parent
|
|
89
|
+
* @param spec - subject OpenApi specification
|
|
90
|
+
*/
|
|
91
|
+
processSchema(schema, parentPath, spec) {
|
|
92
|
+
const schemaObj = this.ifConsolidationCandidate(schema);
|
|
93
|
+
if (schemaObj) {
|
|
94
|
+
// name collison protection
|
|
95
|
+
let instanceNo = 1;
|
|
96
|
+
let title = schemaObj.title;
|
|
97
|
+
let refSchema = this.getRefSchema(title, spec);
|
|
98
|
+
while (refSchema &&
|
|
99
|
+
!json_schema_compare_1.default(schemaObj, refSchema, {
|
|
100
|
+
ignore: ['description'],
|
|
101
|
+
})) {
|
|
102
|
+
title = `${schemaObj.title}${instanceNo++}`;
|
|
103
|
+
refSchema = this.getRefSchema(title, spec);
|
|
77
104
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* set then we consider current schema for consolidation. SchemaObjects with
|
|
82
|
-
* properties (and title set) are moved to #/components/schemas/<title> and
|
|
83
|
-
* replaced with ReferenceObject.
|
|
84
|
-
*
|
|
85
|
-
* Features:
|
|
86
|
-
* - name collision protection
|
|
87
|
-
*
|
|
88
|
-
* @param schema - current schema element to process
|
|
89
|
-
* @param parentPath - path object to parent
|
|
90
|
-
* @param spec - subject OpenApi specification
|
|
91
|
-
*/
|
|
92
|
-
processSchema(schema, parentPath, spec) {
|
|
93
|
-
const schemaObj = this.ifConsolidationCandidate(schema);
|
|
94
|
-
if (schemaObj) {
|
|
95
|
-
// name collison protection
|
|
96
|
-
let instanceNo = 1;
|
|
97
|
-
let title = schemaObj.title;
|
|
98
|
-
let refSchema = this.getRefSchema(title, spec);
|
|
99
|
-
while (refSchema &&
|
|
100
|
-
!json_schema_compare_1.default(schemaObj, refSchema, {
|
|
101
|
-
ignore: ['description'],
|
|
102
|
-
})) {
|
|
103
|
-
title = `${schemaObj.title}${instanceNo++}`;
|
|
104
|
-
refSchema = this.getRefSchema(title, spec);
|
|
105
|
-
}
|
|
106
|
-
if (!refSchema) {
|
|
107
|
-
debug('Creating new component $ref with schema %j', schema);
|
|
108
|
-
this.patchRef(title, schema, spec);
|
|
109
|
-
}
|
|
110
|
-
debug('Creating link to $ref %j', title);
|
|
111
|
-
this.patchPath(title, parentPath, spec);
|
|
105
|
+
if (!refSchema) {
|
|
106
|
+
debug('Creating new component $ref with schema %j', schema);
|
|
107
|
+
this.patchRef(title, schema, spec);
|
|
112
108
|
}
|
|
109
|
+
debug('Creating link to $ref %j', title);
|
|
110
|
+
this.patchPath(title, parentPath, spec);
|
|
113
111
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
})();
|
|
112
|
+
}
|
|
113
|
+
getRefSchema(name, spec) {
|
|
114
|
+
const schema = lodash_1.default.get(spec, ['components', 'schemas', name]);
|
|
115
|
+
return schema;
|
|
116
|
+
}
|
|
117
|
+
patchRef(name, value, spec) {
|
|
118
|
+
lodash_1.default.set(spec, ['components', 'schemas', name], value);
|
|
119
|
+
}
|
|
120
|
+
patchPath(name, path, spec) {
|
|
121
|
+
const patch = {
|
|
122
|
+
$ref: `#/components/schemas/${name}`,
|
|
123
|
+
};
|
|
124
|
+
lodash_1.default.set(spec, path, patch);
|
|
125
|
+
}
|
|
126
|
+
ifConsolidationCandidate(schema) {
|
|
127
|
+
// use title to discriminate references
|
|
128
|
+
return openapi_v3_1.isSchemaObject(schema) && schema.properties && schema.title
|
|
129
|
+
? schema
|
|
130
|
+
: undefined;
|
|
131
|
+
}
|
|
132
|
+
isTraversable(schema) {
|
|
133
|
+
return schema && typeof schema === 'object' ? true : false;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
ConsolidationEnhancer = tslib_1.__decorate([
|
|
137
|
+
core_1.bind(openapi_v3_1.asSpecEnhancer, { scope: core_1.BindingScope.SINGLETON }),
|
|
138
|
+
tslib_1.__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_CONFIG, { optional: true })),
|
|
139
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
140
|
+
], ConsolidationEnhancer);
|
|
144
141
|
exports.ConsolidationEnhancer = ConsolidationEnhancer;
|
|
145
142
|
//# sourceMappingURL=consolidate.spec-enhancer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidate.spec-enhancer.js","sourceRoot":"","sources":["../../src/spec-enhancers/consolidate.spec-enhancer.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAMwB;AACxB,qDAQ8B;AAC9B,0DAAiC;AACjC,sFAA0C;AAC1C,4DAAuB;AAEvB,MAAM,KAAK,GAAG,eAAY,CAAC,4CAA4C,CAAC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH
|
|
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AAI,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;QAE5D,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,QAAQ,CACd,IAAY,EACZ,KAA8B,EAC9B,IAAiB;QAEjB,gBAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAEO,SAAS,CAAC,IAAY,EAAE,IAAmB,EAAE,IAAiB;QACpE,MAAM,KAAK,GAAG;YACZ,IAAI,EAAE,wBAAwB,IAAI,EAAE;SACrC,CAAC;QACF,gBAAC,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3B,CAAC;IAEO,wBAAwB,CAC9B,MAAsC;QAEtC,uCAAuC;QACvC,OAAO,2BAAc,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,KAAK;YAChE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEO,aAAa,CAAC,MAA+B;QACnD,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7D,CAAC;CACF,CAAA;AAxHY,qBAAqB;IADjC,WAAI,CAAC,2BAAc,EAAE,EAAC,KAAK,EAAE,mBAAY,CAAC,SAAS,EAAC,CAAC;IAMjD,mBAAA,aAAM,CAAC,mBAAY,CAAC,kBAAkB,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;GALjD,qBAAqB,CAwHjC;AAxHY,sDAAqB"}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// Node module: @loopback/rest
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var InfoSpecEnhancer_1;
|
|
6
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
8
|
exports.InfoSpecEnhancer = void 0;
|
|
8
9
|
const tslib_1 = require("tslib");
|
|
9
|
-
const context_1 = require("@loopback/context");
|
|
10
10
|
const core_1 = require("@loopback/core");
|
|
11
11
|
const openapi_v3_1 = require("@loopback/openapi-v3");
|
|
12
12
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -15,75 +15,71 @@ const debug = debug_1.default('loopback:openapi:spec-enhancer:info');
|
|
|
15
15
|
* An OpenAPI spec enhancer to populate `info` with application metadata
|
|
16
16
|
* (package.json).
|
|
17
17
|
*/
|
|
18
|
-
let InfoSpecEnhancer =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
let InfoSpecEnhancer = InfoSpecEnhancer_1 = class InfoSpecEnhancer {
|
|
19
|
+
constructor(pkg) {
|
|
20
|
+
this.pkg = pkg;
|
|
21
|
+
this.name = 'info';
|
|
22
|
+
}
|
|
23
|
+
modifySpec(spec) {
|
|
24
|
+
if (this.pkg == null) {
|
|
25
|
+
debug('Application metadata is not found. Skipping spec enhancing.');
|
|
26
|
+
return spec;
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
const contact = InfoSpecEnhancer_1.parseAuthor(this.pkg.author);
|
|
29
|
+
const patchSpec = {
|
|
30
|
+
info: {
|
|
31
|
+
title: this.pkg.name,
|
|
32
|
+
description: this.pkg.description,
|
|
33
|
+
version: this.pkg.version,
|
|
34
|
+
contact,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
debug('Enhancing OpenAPI spec with %j', patchSpec);
|
|
38
|
+
return openapi_v3_1.mergeOpenAPISpec(spec, patchSpec);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse package.json
|
|
42
|
+
* {@link https://docs.npmjs.com/files/package.json#people-fields-author-contributors | author}
|
|
43
|
+
*
|
|
44
|
+
* @param author - Author string or object from package.json
|
|
45
|
+
*/
|
|
46
|
+
static parseAuthor(author) {
|
|
47
|
+
var _a, _b, _c, _d, _e, _f;
|
|
48
|
+
let contact = {};
|
|
49
|
+
if (author == null) {
|
|
50
|
+
contact = {};
|
|
51
|
+
}
|
|
52
|
+
else if (typeof author === 'string') {
|
|
53
|
+
// "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
|
|
54
|
+
const emailRegex = /<([^<>]+)>/; // <email>
|
|
55
|
+
const urlRegex = /\(([^()]+)\)/; // (url)
|
|
56
|
+
const nameRegex = /([^<>()]+)/;
|
|
57
|
+
contact = {
|
|
58
|
+
name: (_b = (_a = nameRegex.exec(author)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.trim(),
|
|
59
|
+
email: (_d = (_c = emailRegex.exec(author)) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.trim(),
|
|
60
|
+
url: (_f = (_e = urlRegex.exec(author)) === null || _e === void 0 ? void 0 : _e[1]) === null || _f === void 0 ? void 0 : _f.trim(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else if (typeof author === 'object') {
|
|
64
|
+
const authorObj = author;
|
|
65
|
+
contact = {
|
|
66
|
+
name: authorObj.name,
|
|
67
|
+
email: authorObj.email,
|
|
68
|
+
url: authorObj.url,
|
|
38
69
|
};
|
|
39
|
-
debug('Enhancing OpenAPI spec with %j', patchSpec);
|
|
40
|
-
return openapi_v3_1.mergeOpenAPISpec(spec, patchSpec);
|
|
41
70
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* @param author - Author string or object from package.json
|
|
47
|
-
*/
|
|
48
|
-
static parseAuthor(author) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f;
|
|
50
|
-
let contact = {};
|
|
51
|
-
if (author == null) {
|
|
52
|
-
contact = {};
|
|
53
|
-
}
|
|
54
|
-
else if (typeof author === 'string') {
|
|
55
|
-
// "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
|
|
56
|
-
const emailRegex = /<([^<>]+)>/; // <email>
|
|
57
|
-
const urlRegex = /\(([^()]+)\)/; // (url)
|
|
58
|
-
const nameRegex = /([^<>()]+)/;
|
|
59
|
-
contact = {
|
|
60
|
-
name: (_b = (_a = nameRegex.exec(author)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.trim(),
|
|
61
|
-
email: (_d = (_c = emailRegex.exec(author)) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.trim(),
|
|
62
|
-
url: (_f = (_e = urlRegex.exec(author)) === null || _e === void 0 ? void 0 : _e[1]) === null || _f === void 0 ? void 0 : _f.trim(),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
else if (typeof author === 'object') {
|
|
66
|
-
const authorObj = author;
|
|
67
|
-
contact = {
|
|
68
|
-
name: authorObj.name,
|
|
69
|
-
email: authorObj.email,
|
|
70
|
-
url: authorObj.url,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
// Remove undefined/null values
|
|
74
|
-
for (const p in contact) {
|
|
75
|
-
if (contact[p] == null)
|
|
76
|
-
delete contact[p];
|
|
77
|
-
}
|
|
78
|
-
return contact;
|
|
71
|
+
// Remove undefined/null values
|
|
72
|
+
for (const p in contact) {
|
|
73
|
+
if (contact[p] == null)
|
|
74
|
+
delete contact[p];
|
|
79
75
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
return contact;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
InfoSpecEnhancer = InfoSpecEnhancer_1 = tslib_1.__decorate([
|
|
80
|
+
core_1.bind(openapi_v3_1.asSpecEnhancer, { scope: core_1.BindingScope.SINGLETON }),
|
|
81
|
+
tslib_1.__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_METADATA, { optional: true })),
|
|
82
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
83
|
+
], InfoSpecEnhancer);
|
|
88
84
|
exports.InfoSpecEnhancer = InfoSpecEnhancer;
|
|
89
85
|
//# sourceMappingURL=info.spec-enhancer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.spec-enhancer.js","sourceRoot":"","sources":["../../src/spec-enhancers/info.spec-enhancer.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"info.spec-enhancer.js","sourceRoot":"","sources":["../../src/spec-enhancers/info.spec-enhancer.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,yCAQwB;AACxB,qDAM8B;AAC9B,0DAAiC;AAEjC,MAAM,KAAK,GAAG,eAAY,CAAC,qCAAqC,CAAC,CAAC;AAElE;;;GAGG;AAEH,IAAa,gBAAgB,wBAA7B,MAAa,gBAAgB;IAG3B,YAEW,GAAyB;QAAzB,QAAG,GAAH,GAAG,CAAsB;QAJpC,SAAI,GAAG,MAAM,CAAC;IAKX,CAAC;IAEJ,UAAU,CAAC,IAAiB;QAC1B,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE;YACpB,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACrE,OAAO,IAAI,CAAC;SACb;QACD,MAAM,OAAO,GAAkB,kBAAgB,CAAC,WAAW,CACzD,IAAI,CAAC,GAAG,CAAC,MAAM,CAChB,CAAC;QACF,MAAM,SAAS,GAAG;YAChB,IAAI,EAAE;gBACJ,KAAK,EAAE,IAAI,CAAC,GA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C,CAAC,IAAI,IAAI;gBAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA9DY,gBAAgB;IAD5B,WAAI,CAAC,2BAAc,EAAE,EAAC,KAAK,EAAE,mBAAY,CAAC,SAAS,EAAC,CAAC;IAKjD,mBAAA,aAAM,CAAC,mBAAY,CAAC,oBAAoB,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;;GAJnD,gBAAgB,CA8D5B;AA9DY,4CAAgB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -77,6 +77,16 @@ export declare type AjvKeyword = KeywordDefinition & {
|
|
|
77
77
|
export declare type AjvFormat = FormatDefinition & {
|
|
78
78
|
name: string;
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Options for any value validation using AJV
|
|
82
|
+
*/
|
|
83
|
+
export interface ValueValidationOptions extends RequestBodyValidationOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Where the data comes from. It can be 'body', 'path', 'header',
|
|
86
|
+
* 'query', 'cookie', etc...
|
|
87
|
+
*/
|
|
88
|
+
source?: string;
|
|
89
|
+
}
|
|
80
90
|
/**
|
|
81
91
|
* Options for request body validation using AJV
|
|
82
92
|
*/
|