@loopback/openapi-v3 1.10.2 → 1.13.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 +44 -0
- package/dist/controller-spec.js +114 -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/deprecated.decorator.d.ts +37 -0
- package/dist/decorators/deprecated.decorator.js +71 -0
- package/dist/decorators/deprecated.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +20 -0
- package/dist/decorators/index.js +24 -0
- package/dist/decorators/index.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/decorators/tags.decorator.d.ts +1 -0
- package/dist/decorators/tags.decorator.js +33 -0
- package/dist/decorators/tags.decorator.js.map +1 -0
- 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 +17 -1
- package/dist/keys.js +22 -10
- package/dist/keys.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +11 -10
- package/src/controller-spec.ts +136 -21
- package/src/decorators/api.decorator.ts +1 -1
- package/src/decorators/deprecated.decorator.ts +87 -0
- package/src/decorators/index.ts +30 -0
- 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/decorators/tags.decorator.ts +46 -0
- 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 +33 -6
- package/src/types.ts +4 -0
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
// Node module: @loopback/openapi-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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AC,EAjCgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAiC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tags(...tagNames: string[]): (target: any, method?: string | undefined, methodDescriptor?: TypedPropertyDescriptor<any> | undefined) => any;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2018. 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
|
+
const keys_1 = require("../keys");
|
|
9
|
+
function tags(...tagNames) {
|
|
10
|
+
return function tagsDecoratorForClassOrMethod(
|
|
11
|
+
// Class or a prototype
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
target, method,
|
|
14
|
+
// Use `any` to for `TypedPropertyDescriptor`
|
|
15
|
+
// See https://github.com/strongloop/loopback-next/pull/2704
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
methodDescriptor) {
|
|
18
|
+
if (method && methodDescriptor) {
|
|
19
|
+
// Method
|
|
20
|
+
return core_1.MethodDecoratorFactory.createDecorator(keys_1.OAI3Keys.TAGS_METHOD_KEY, { tags: tagNames }, { decoratorName: '@oas.tags' })(target, method, methodDescriptor);
|
|
21
|
+
}
|
|
22
|
+
else if (typeof target === 'function' && !method && !methodDescriptor) {
|
|
23
|
+
// Class
|
|
24
|
+
return core_1.ClassDecoratorFactory.createDecorator(keys_1.OAI3Keys.TAGS_CLASS_KEY, { tags: tagNames }, { decoratorName: '@oas.tags' })(target);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error('@oas.tags cannot be used on a property: ' +
|
|
28
|
+
core_1.DecoratorFactory.getTargetName(target, method, methodDescriptor));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.tags = tags;
|
|
33
|
+
//# sourceMappingURL=tags.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.decorator.js","sourceRoot":"","sources":["../../src/decorators/tags.decorator.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAIwB;AACxB,kCAAiC;AAGjC,SAAgB,IAAI,CAAC,GAAG,QAAkB;IACxC,OAAO,SAAS,6BAA6B;IAC3C,uBAAuB;IACvB,8DAA8D;IAC9D,MAAW,EACX,MAAe;IACf,6CAA6C;IAC7C,4DAA4D;IAC5D,8DAA8D;IAC9D,gBAA+C;QAE/C,IAAI,MAAM,IAAI,gBAAgB,EAAE;YAC9B,SAAS;YACT,OAAO,6BAAsB,CAAC,eAAe,CAC3C,eAAQ,CAAC,eAAe,EACxB,EAAC,IAAI,EAAE,QAAQ,EAAC,EAChB,EAAC,aAAa,EAAE,WAAW,EAAC,CAC7B,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;SACrC;aAAM,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,gBAAgB,EAAE;YACvE,QAAQ;YACR,OAAO,4BAAqB,CAAC,eAAe,CAC1C,eAAQ,CAAC,cAAc,EACvB,EAAC,IAAI,EAAE,QAAQ,EAAC,EAChB,EAAC,aAAa,EAAE,WAAW,EAAC,CAC7B,CAAC,MAAM,CAAC,CAAC;SACX;aAAM;YACL,MAAM,IAAI,KAAK,CACb,0CAA0C;gBACxC,uBAAgB,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CACnE,CAAC;SACH;IACH,CAAC,CAAC;AACJ,CAAC;AAhCD,oBAgCC"}
|
|
@@ -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;
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
14
|
+
};
|
|
15
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
25
|
+
result["default"] = mod;
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const core_1 = require("@loopback/core");
|
|
30
|
+
const debug_1 = __importDefault(require("debug"));
|
|
31
|
+
const _ = __importStar(require("lodash"));
|
|
32
|
+
const util_1 = require("util");
|
|
33
|
+
const types_1 = require("./types");
|
|
34
|
+
const jsonmergepatch = require('json-merge-patch');
|
|
35
|
+
const debug = debug_1.default('loopback:openapi:spec-enhancer');
|
|
36
|
+
/**
|
|
37
|
+
* An extension point for OpenAPI Spec enhancement
|
|
38
|
+
* This service is used for enhancing an OpenAPI spec by loading and applying one or more
|
|
39
|
+
* registered enhancers.
|
|
40
|
+
*
|
|
41
|
+
* A typical use of it would be generating the OpenAPI spec for the endpoints on a server
|
|
42
|
+
* in the `@loopback/rest` module.
|
|
43
|
+
*/
|
|
44
|
+
let OASEnhancerService = class OASEnhancerService {
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Inject a getter function to fetch spec enhancers
|
|
48
|
+
*/
|
|
49
|
+
getEnhancers,
|
|
50
|
+
/**
|
|
51
|
+
* An extension point should be able to receive its options via dependency
|
|
52
|
+
* injection.
|
|
53
|
+
*/
|
|
54
|
+
options) {
|
|
55
|
+
this.getEnhancers = getEnhancers;
|
|
56
|
+
this.options = options;
|
|
57
|
+
this._spec = {
|
|
58
|
+
openapi: '3.0.0',
|
|
59
|
+
info: {
|
|
60
|
+
title: 'LoopBack Application',
|
|
61
|
+
version: '1.0.0',
|
|
62
|
+
},
|
|
63
|
+
paths: {},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Getter for `_spec`
|
|
68
|
+
*/
|
|
69
|
+
get spec() {
|
|
70
|
+
return this._spec;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Setter for `_spec`
|
|
74
|
+
*/
|
|
75
|
+
set spec(value) {
|
|
76
|
+
this._spec = value;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Find an enhancer by its name
|
|
80
|
+
* @param name The name of the enhancer you want to find
|
|
81
|
+
*/
|
|
82
|
+
async getEnhancerByName(name) {
|
|
83
|
+
// Get the latest list of enhancers
|
|
84
|
+
const enhancers = await this.getEnhancers();
|
|
85
|
+
return enhancers.find(e => e.name === name);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Apply a given enhancer's merge function. Return the latest _spec.
|
|
89
|
+
* @param name The name of the enhancer you want to apply
|
|
90
|
+
*/
|
|
91
|
+
async applyEnhancerByName(name) {
|
|
92
|
+
const enhancer = await this.getEnhancerByName(name);
|
|
93
|
+
if (enhancer)
|
|
94
|
+
this._spec = enhancer.modifySpec(this._spec);
|
|
95
|
+
return this._spec;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generate OpenAPI spec by applying ALL registered enhancers
|
|
99
|
+
* TBD: load enhancers by group names
|
|
100
|
+
*/
|
|
101
|
+
async applyAllEnhancers(options = {}) {
|
|
102
|
+
const enhancers = await this.getEnhancers();
|
|
103
|
+
if (_.isEmpty(enhancers))
|
|
104
|
+
return this._spec;
|
|
105
|
+
for (const e of enhancers) {
|
|
106
|
+
this._spec = e.modifySpec(this._spec);
|
|
107
|
+
}
|
|
108
|
+
debug(`Spec enhancer service, generated spec: ${util_1.inspect(this._spec)}`);
|
|
109
|
+
return this._spec;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
OASEnhancerService = __decorate([
|
|
113
|
+
core_1.extensionPoint(types_1.OAS_ENHANCER_EXTENSION_POINT_NAME),
|
|
114
|
+
__param(0, core_1.extensions()),
|
|
115
|
+
__param(1, core_1.config()),
|
|
116
|
+
__metadata("design:paramtypes", [Function, Object])
|
|
117
|
+
], OASEnhancerService);
|
|
118
|
+
exports.OASEnhancerService = OASEnhancerService;
|
|
119
|
+
/**
|
|
120
|
+
* The default merge function to patch the current OpenAPI spec.
|
|
121
|
+
* It leverages module `json-merge-patch`'s merge API to merge two json objects.
|
|
122
|
+
* It returns a new merged object without modifying the original one.
|
|
123
|
+
*
|
|
124
|
+
* A list of merging rules can be found in test file:
|
|
125
|
+
* https://github.com/pierreinglebert/json-merge-patch/blob/master/test/lib/merge.js
|
|
126
|
+
*
|
|
127
|
+
* @param currentSpec The original spec
|
|
128
|
+
* @param patchSpec The patch spec to be merged into the original spec
|
|
129
|
+
*/
|
|
130
|
+
function mergeOpenAPISpec(currentSpec, patchSpec) {
|
|
131
|
+
const mergedSpec = jsonmergepatch.merge(currentSpec, patchSpec);
|
|
132
|
+
return mergedSpec;
|
|
133
|
+
}
|
|
134
|
+
exports.mergeOpenAPISpec = mergeOpenAPISpec;
|
|
135
|
+
//# sourceMappingURL=spec-enhancer.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-enhancer.service.js","sourceRoot":"","sources":["../../src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AQ;YAAE,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,OAAO,GAAG,EAAE;QAClC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC5C,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QAC5C,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACzB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvC;QACD,KAAK,CAAC,0CAA0C,cAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAA;AAtEY,kBAAkB;IAD9B,qBAAc,CAAC,yCAAiC,CAAC;IAM7C,WAAA,iBAAU,EAAE,CAAA;IAMZ,WAAA,aAAM,EAAE,CAAA;;GAXA,kBAAkB,CAsE9B;AAtEY,gDAAkB;AAwE/B;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAC9B,WAAiC,EACjC,SAA+B;IAE/B,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAChE,OAAO,UAAU,CAAC;AACpB,CAAC;AAND,4CAMC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BindingTemplate } from '@loopback/core';
|
|
2
|
+
import { OpenApiSpec } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Typically an extension point defines an interface as the contract for
|
|
5
|
+
* extensions to implement
|
|
6
|
+
*/
|
|
7
|
+
export interface OASEnhancer {
|
|
8
|
+
name: string;
|
|
9
|
+
modifySpec(spec: OpenApiSpec): OpenApiSpec;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Name/id of the OAS enhancer extension point
|
|
13
|
+
*/
|
|
14
|
+
export declare const OAS_ENHANCER_EXTENSION_POINT_NAME = "oas-enhancer";
|
|
15
|
+
/**
|
|
16
|
+
* A binding template for spec contributor extensions
|
|
17
|
+
*/
|
|
18
|
+
export declare const asSpecEnhancer: BindingTemplate;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
* Name/id of the OAS enhancer extension point
|
|
10
|
+
*/
|
|
11
|
+
exports.OAS_ENHANCER_EXTENSION_POINT_NAME = 'oas-enhancer';
|
|
12
|
+
/**
|
|
13
|
+
* A binding template for spec contributor extensions
|
|
14
|
+
*/
|
|
15
|
+
exports.asSpecEnhancer = binding => {
|
|
16
|
+
core_1.extensionFor(exports.OAS_ENHANCER_EXTENSION_POINT_NAME)(binding);
|
|
17
|
+
// is it ok to have a different namespace than the extension point name?
|
|
18
|
+
binding.tag({ namespace: 'oas-enhancer' });
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/enhancers/types.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAA6D;AAY7D;;GAEG;AACU,QAAA,iCAAiC,GAAG,cAAc,CAAC;AAEhE;;GAEG;AACU,QAAA,cAAc,GAAoB,OAAO,CAAC,EAAE;IACvD,mBAAY,CAAC,yCAAiC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzD,wEAAwE;IACxE,OAAO,CAAC,GAAG,CAAC,EAAC,SAAS,EAAE,cAAc,EAAC,CAAC,CAAC;AAC3C,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
__export(require("@loopback/repository-json-schema"));
|
|
11
11
|
__export(require("./controller-spec"));
|
|
12
12
|
__export(require("./decorators"));
|
|
13
|
+
__export(require("./enhancers"));
|
|
13
14
|
__export(require("./filter-schema"));
|
|
14
15
|
__export(require("./json-to-schema"));
|
|
15
16
|
__export(require("./types"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,sDAAiD;AACjD,uCAAkC;AAClC,kCAA6B;AAC7B,qCAAgC;AAChC,sCAAiC;AACjC,6BAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,sDAAiD;AACjD,uCAAkC;AAClC,kCAA6B;AAC7B,iCAA4B;AAC5B,qCAAgC;AAChC,sCAAiC;AACjC,6BAAwB"}
|
package/dist/json-to-schema.js
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
// Node module: @loopback/openapi-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
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
11
|
const types_1 = require("./types");
|
|
9
12
|
/**
|
|
10
13
|
* Converts JSON Schemas into a SchemaObject
|
|
@@ -25,13 +28,7 @@ function jsonToSchemaObject(json, visited = new Map()) {
|
|
|
25
28
|
[converted]: false,
|
|
26
29
|
};
|
|
27
30
|
visited.set(json, result);
|
|
28
|
-
const propsToIgnore = [
|
|
29
|
-
'anyOf',
|
|
30
|
-
'oneOf',
|
|
31
|
-
'additionalItems',
|
|
32
|
-
'defaultProperties',
|
|
33
|
-
'typeof',
|
|
34
|
-
];
|
|
31
|
+
const propsToIgnore = ['additionalItems', 'defaultProperties', 'typeof'];
|
|
35
32
|
for (const property in json) {
|
|
36
33
|
if (propsToIgnore.includes(property)) {
|
|
37
34
|
continue;
|
|
@@ -45,15 +42,23 @@ function jsonToSchemaObject(json, visited = new Map()) {
|
|
|
45
42
|
break;
|
|
46
43
|
}
|
|
47
44
|
case 'allOf': {
|
|
48
|
-
result.allOf =
|
|
45
|
+
result.allOf = lodash_1.default.map(json.allOf, item => jsonToSchemaObject(item, visited));
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'anyOf': {
|
|
49
|
+
result.anyOf = lodash_1.default.map(json.anyOf, item => jsonToSchemaObject(item, visited));
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'oneOf': {
|
|
53
|
+
result.oneOf = lodash_1.default.map(json.oneOf, item => jsonToSchemaObject(item, visited));
|
|
49
54
|
break;
|
|
50
55
|
}
|
|
51
56
|
case 'definitions': {
|
|
52
|
-
result.definitions =
|
|
57
|
+
result.definitions = lodash_1.default.mapValues(json.definitions, def => jsonToSchemaObject(jsonOrBooleanToJSON(def), visited));
|
|
53
58
|
break;
|
|
54
59
|
}
|
|
55
60
|
case 'properties': {
|
|
56
|
-
result.properties =
|
|
61
|
+
result.properties = lodash_1.default.mapValues(json.properties, item => jsonToSchemaObject(jsonOrBooleanToJSON(item), visited));
|
|
57
62
|
break;
|
|
58
63
|
}
|
|
59
64
|
case 'additionalProperties': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-to-schema.js","sourceRoot":"","sources":["../src/json-to-schema.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"json-to-schema.js","sourceRoot":"","sources":["../src/json-to-schema.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAGhE,oDAAuB;AACvB,mCAKiB;AAwBjB;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,IAAgB,EAChB,UAAqD,IAAI,GAAG,EAAE;IAE9D,wDAAwD;IACxD,MAAM,SAAS,GAAG,sBAAsB,CAAC;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,MAAM,IAAI,IAAI,IAAI,sBAAc,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE;QAC3E,OAAO,EAAC,IAAI,EAAE,wBAAwB,IAAI,CAAC,KAAK,EAAE,EAAC,CAAC;KACrD;IACD,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,MAAM,CAAC;IAElC,MAAM,MAAM,GAAiB;QAC3B,CAAC,SAAS,CAAC,EAAE,KAAK;KACnB,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,aAAa,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzE,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE;QAC3B,IAAI,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACpC,SAAS;SACV;QACD,QAAQ,QAAQ,EAAE;YAChB,KAA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,CAAC,SAAS,CAAC,CAAC;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC;AAnGD,gDAmGC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,UAAgC;IAClE,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACnB;SAAM;QACL,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,GAAG,EAAE,EAAE,EAAC,CAAC;KACpC;AACH,CAAC;AAND,kDAMC"}
|
package/dist/keys.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetadataAccessor } from '@loopback/
|
|
1
|
+
import { MetadataAccessor } from '@loopback/core';
|
|
2
2
|
import { ControllerSpec, RestEndpoint } from './controller-spec';
|
|
3
3
|
import { ParameterObject, RequestBodyObject } from './types';
|
|
4
4
|
export declare namespace OAI3Keys {
|
|
@@ -6,10 +6,26 @@ export declare namespace OAI3Keys {
|
|
|
6
6
|
* Metadata key used to set or retrieve `@operation` metadata.
|
|
7
7
|
*/
|
|
8
8
|
const METHODS_KEY: MetadataAccessor<Partial<RestEndpoint>, MethodDecorator>;
|
|
9
|
+
/**
|
|
10
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a method.
|
|
11
|
+
*/
|
|
12
|
+
const DEPRECATED_METHOD_KEY: MetadataAccessor<boolean, MethodDecorator>;
|
|
13
|
+
/**
|
|
14
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a class
|
|
15
|
+
*/
|
|
16
|
+
const DEPRECATED_CLASS_KEY: MetadataAccessor<boolean, ClassDecorator>;
|
|
9
17
|
/**
|
|
10
18
|
* Metadata key used to set or retrieve `param` decorator metadata
|
|
11
19
|
*/
|
|
12
20
|
const PARAMETERS_KEY: MetadataAccessor<ParameterObject, ParameterDecorator>;
|
|
21
|
+
/**
|
|
22
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a method.
|
|
23
|
+
*/
|
|
24
|
+
const TAGS_METHOD_KEY: MetadataAccessor<string[], MethodDecorator>;
|
|
25
|
+
/**
|
|
26
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a class
|
|
27
|
+
*/
|
|
28
|
+
const TAGS_CLASS_KEY: MetadataAccessor<string[], ClassDecorator>;
|
|
13
29
|
/**
|
|
14
30
|
* Metadata key used to set or retrieve `@api` metadata
|
|
15
31
|
*/
|
package/dist/keys.js
CHANGED
|
@@ -4,32 +4,44 @@
|
|
|
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
|
|
8
|
-
// Copyright IBM Corp. 2018. All Rights Reserved.
|
|
9
|
-
// Node module: @loopback/openapi-v3
|
|
10
|
-
// This file is licensed under the MIT License.
|
|
11
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
12
8
|
var OAI3Keys;
|
|
13
9
|
(function (OAI3Keys) {
|
|
14
10
|
/**
|
|
15
11
|
* Metadata key used to set or retrieve `@operation` metadata.
|
|
16
12
|
*/
|
|
17
|
-
OAI3Keys.METHODS_KEY =
|
|
13
|
+
OAI3Keys.METHODS_KEY = core_1.MetadataAccessor.create('openapi-v3:methods');
|
|
14
|
+
/**
|
|
15
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a method.
|
|
16
|
+
*/
|
|
17
|
+
OAI3Keys.DEPRECATED_METHOD_KEY = core_1.MetadataAccessor.create('openapi-v3:methods:deprecated');
|
|
18
|
+
/**
|
|
19
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a class
|
|
20
|
+
*/
|
|
21
|
+
OAI3Keys.DEPRECATED_CLASS_KEY = core_1.MetadataAccessor.create('openapi-v3:class:deprecated');
|
|
18
22
|
/**
|
|
19
23
|
* Metadata key used to set or retrieve `param` decorator metadata
|
|
20
24
|
*/
|
|
21
|
-
OAI3Keys.PARAMETERS_KEY =
|
|
25
|
+
OAI3Keys.PARAMETERS_KEY = core_1.MetadataAccessor.create('openapi-v3:parameters');
|
|
26
|
+
/**
|
|
27
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a method.
|
|
28
|
+
*/
|
|
29
|
+
OAI3Keys.TAGS_METHOD_KEY = core_1.MetadataAccessor.create('openapi-v3:methods:tags');
|
|
30
|
+
/**
|
|
31
|
+
* Metadata key used to set or retrieve `@deprecated` metadata on a class
|
|
32
|
+
*/
|
|
33
|
+
OAI3Keys.TAGS_CLASS_KEY = core_1.MetadataAccessor.create('openapi-v3:class:tags');
|
|
22
34
|
/**
|
|
23
35
|
* Metadata key used to set or retrieve `@api` metadata
|
|
24
36
|
*/
|
|
25
|
-
OAI3Keys.CLASS_KEY =
|
|
37
|
+
OAI3Keys.CLASS_KEY = core_1.MetadataAccessor.create('openapi-v3:class');
|
|
26
38
|
/**
|
|
27
39
|
* Metadata key used to set or retrieve a controller spec
|
|
28
40
|
*/
|
|
29
|
-
OAI3Keys.CONTROLLER_SPEC_KEY =
|
|
41
|
+
OAI3Keys.CONTROLLER_SPEC_KEY = core_1.MetadataAccessor.create('openapi-v3:controller-spec');
|
|
30
42
|
/**
|
|
31
43
|
* Metadata key used to set or retrieve `@requestBody` metadata
|
|
32
44
|
*/
|
|
33
|
-
OAI3Keys.REQUEST_BODY_KEY =
|
|
45
|
+
OAI3Keys.REQUEST_BODY_KEY = core_1.MetadataAccessor.create('openapi-v3:request-body');
|
|
34
46
|
})(OAI3Keys = exports.OAI3Keys || (exports.OAI3Keys = {}));
|
|
35
47
|
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAAgD;AAIhD,IAAiB,QAAQ,CAwExB;AAxED,WAAiB,QAAQ;IACvB;;OAEG;IACU,oBAAW,GAAG,uBAAgB,CAAC,MAAM,CAGhD,oBAAoB,CAAC,CAAC;IAExB;;OAEG;IACU,8BAAqB,GAAG,uBAAgB,CAAC,MAAM,CAG1D,+BAA+B,CAAC,CAAC;IAEnC;;OAEG;IACU,6BAAoB,GAAG,uBAAgB,CAAC,MAAM,CAGzD,6BAA6B,CAAC,CAAC;IAEjC;;OAEG;IACU,uBAAc,GAAG,uBAAgB,CAAC,MAAM,CAGnD,uBAAuB,CAAC,CAAC;IAE3B;;OAEG;IACU,wBAAe,GAAG,uBAAgB,CAAC,MAAM,CAGpD,yBAAyB,CAAC,CAAC;IAE7B;;OAEG;IACU,uBAAc,GAAG,uBAAgB,CAAC,MAAM,CAGnD,uBAAuB,CAAC,CAAC;IAE3B;;OAEG;IACU,kBAAS,GAAG,uBAAgB,CAAC,MAAM,CAG9C,kBAAkB,CAAC,CAAC;IAEtB;;OAEG;IACU,4BAAmB,GAAG,uBAAgB,CAAC,MAAM,CAGxD,4BAA4B,CAAC,CAAC;IAEhC;;OAEG;IACU,yBAAgB,GAAG,uBAAgB,CAAC,MAAM,CAGrD,yBAAyB,CAAC,CAAC;AAC/B,CAAC,EAxEgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAwExB"}
|