@loopback/openapi-v3 1.10.3 → 2.0.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 +131 -0
- package/dist/controller-spec.js +114 -35
- 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 +13 -6
- package/dist/decorators/parameter.decorator.js.map +1 -1
- package/dist/decorators/request-body.decorator.js +3 -3
- 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 +9 -7
- 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 +134 -19
- 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 +11 -6
- package/src/decorators/request-body.decorator.ts +1 -1
- 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 +13 -7
- package/src/keys.ts +33 -6
- package/src/types.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,137 @@
|
|
|
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
|
+
# [2.0.0](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.13.0...@loopback/openapi-v3@2.0.0) (2020-02-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* suport complex objects for query params in api explorer ([a4ef640](https://github.com/strongloop/loopback-next/commit/a4ef64037a80d1ff7df37ba7912909a1bfcdbf51))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* This fix has modified the api definitions described by the decorator
|
|
17
|
+
'param.query.object', to support Open-API's `url-encoded` definition for json query
|
|
18
|
+
parameters.
|
|
19
|
+
|
|
20
|
+
Previously, such parameters were described with `exploded: true` and
|
|
21
|
+
`style: deepObject`, i.e exploded encoding, which turned out to be problematic as explained and discussed in,
|
|
22
|
+
https://github.com/swagger-api/swagger-js/issues/1385 and
|
|
23
|
+
https://github.com/OAI/OpenAPI-Specification/issues/1706
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"in": "query",
|
|
28
|
+
"style": "deepObject"
|
|
29
|
+
"explode": "true",
|
|
30
|
+
"schema": {}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Exploded encoding worked for simple json objects as below but not for complex objects.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
http://localhost:3000/todos?filter[limit]=2
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To address these issues with exploded queries, this fix switches definition of json
|
|
41
|
+
query params from the `exploded`, `deep-object` style to the `url-encoded` style
|
|
42
|
+
definition in Open-API spec.
|
|
43
|
+
|
|
44
|
+
LoopBack already supports receiving url-encoded payload for json query parameters.
|
|
45
|
+
|
|
46
|
+
For instance, to filter api results from the GET '/todo-list' endpoint in the
|
|
47
|
+
todo-list example with a specific relation, { "include": [ { "relation": "todo" } ] },
|
|
48
|
+
the following url-encoded query parameter can be used,
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
http://localhost:3000/todos?filter=%7B%22include%22%3A%5B%7B%22relation%22%3A%22todoList%22%7D%5D%7D
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The above was possible because the coercion behavior in LoopBack performed json
|
|
55
|
+
parsing for `deep object` style json query params before this fix. This fix has
|
|
56
|
+
modified that behavior by removing json parsing. Since the `exploded` `deep-object`
|
|
57
|
+
definition has been removed from the `param.query.object` decorator, this new
|
|
58
|
+
behaviour remains just an internal source code aspect as of now.
|
|
59
|
+
|
|
60
|
+
In effect, this fix only modifies the open api definitions generated from LoopBack
|
|
61
|
+
APIs. The 'style' and 'explode' fields are removed and the 'schema' field is moved
|
|
62
|
+
under 'content[application/json]'. This is the definition that supports url-encoding
|
|
63
|
+
as per Open-API spec.
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"in": "query"
|
|
68
|
+
"content": {
|
|
69
|
+
"application/json": {
|
|
70
|
+
"schema": {}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Certain client libraries (like swagger-ui or LoopBack's api explorer) necessiate
|
|
77
|
+
using Open-API's `url-encoded` style definition for json query params to support
|
|
78
|
+
"sending" url-encoded payload.
|
|
79
|
+
|
|
80
|
+
All consumers of LoopBack APIs may need to regenerate api definitions, if their
|
|
81
|
+
client libraries require them to do so for url-encoding.
|
|
82
|
+
|
|
83
|
+
Otherwise there wouldn't be any significant impact on API consumers.
|
|
84
|
+
|
|
85
|
+
To preserve compatibility with existing REST API clients, this change is backward
|
|
86
|
+
compatible. All exploded queries like `?filter[limit]=1` will continue to work for
|
|
87
|
+
json query params, despite the fact that they are described differently in the
|
|
88
|
+
OpenAPI spec.
|
|
89
|
+
|
|
90
|
+
Existing api clients will continue to work after an upgrade.
|
|
91
|
+
|
|
92
|
+
The signature of the 'param.query.object' decorator has not changed.
|
|
93
|
+
|
|
94
|
+
There is no code changes required in the LoopBack APIs after upgrading to this
|
|
95
|
+
fix. No method signatures or data structures are impacted.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# [1.13.0](https://github.com/strongloop/loopback-next/compare/@loopback/openapi-v3@1.12.0...@loopback/openapi-v3@1.13.0) (2020-02-05)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Features
|
|
105
|
+
|
|
106
|
+
* adds [@oas](https://github.com/oas).deprecated() decorator ([6b6b5f0](https://github.com/strongloop/loopback-next/commit/6b6b5f05d224053d6a9735a506841d19b7331dac))
|
|
107
|
+
* adds [@oas](https://github.com/oas).tags convenience decorator ([a8722dc](https://github.com/strongloop/loopback-next/commit/a8722dc68838344684a5d3de76fa6915e08d2e56))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# [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)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### Features
|
|
117
|
+
|
|
118
|
+
* support x-ts-type in anyOf/allOf/oneOf/not ([28fcc54](https://github.com/strongloop/loopback-next/commit/28fcc545e42d4c5ae88215436b873a78a3fb6c8d))
|
|
119
|
+
* **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)
|
|
120
|
+
* **repository-json-schema:** add title to filter schemas ([6105883](https://github.com/strongloop/loopback-next/commit/6105883967ca5853cc8990f423d9febd1eb07101))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# [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)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### Features
|
|
130
|
+
|
|
131
|
+
* openapi spec contributor extension point ([9fee3f3](https://github.com/strongloop/loopback-next/commit/9fee3f342ff76d65d1899ddf1dbf7a257c85ea26))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
6
137
|
## [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)
|
|
7
138
|
|
|
8
139
|
**Note:** Version bump only for package @loopback/openapi-v3
|
package/dist/controller-spec.js
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
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
|
-
};
|
|
9
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
7
|
+
const core_1 = require("@loopback/core");
|
|
11
8
|
const repository_json_schema_1 = require("@loopback/repository-json-schema");
|
|
12
|
-
const lodash_1 =
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
13
10
|
const generate_schema_1 = require("./generate-schema");
|
|
14
11
|
const json_to_schema_1 = require("./json-to-schema");
|
|
15
12
|
const keys_1 = require("./keys");
|
|
@@ -21,23 +18,59 @@ exports.TS_TYPE_KEY = 'x-ts-type';
|
|
|
21
18
|
* @param constructor - Controller class
|
|
22
19
|
*/
|
|
23
20
|
function resolveControllerSpec(constructor) {
|
|
24
|
-
var _a, _b;
|
|
21
|
+
var _a, _b, _c, _d;
|
|
25
22
|
debug(`Retrieving OpenAPI specification for controller ${constructor.name}`);
|
|
26
|
-
let spec =
|
|
23
|
+
let spec = core_1.MetadataInspector.getClassMetadata(keys_1.OAI3Keys.CLASS_KEY, constructor);
|
|
27
24
|
if (spec) {
|
|
28
25
|
debug(' using class-level spec defined via @api()', spec);
|
|
29
|
-
spec =
|
|
26
|
+
spec = core_1.DecoratorFactory.cloneDeep(spec);
|
|
30
27
|
}
|
|
31
28
|
else {
|
|
32
29
|
spec = { paths: {} };
|
|
33
30
|
}
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const isClassDeprecated = core_1.MetadataInspector.getClassMetadata(keys_1.OAI3Keys.DEPRECATED_CLASS_KEY, constructor);
|
|
32
|
+
if (isClassDeprecated) {
|
|
33
|
+
debug(' using class-level @deprecated()');
|
|
34
|
+
}
|
|
35
|
+
const classTags = core_1.MetadataInspector.getClassMetadata(keys_1.OAI3Keys.TAGS_CLASS_KEY, constructor);
|
|
36
|
+
if (classTags) {
|
|
37
|
+
debug(' using class-level @oas.tags()');
|
|
38
|
+
}
|
|
39
|
+
if (classTags || isClassDeprecated) {
|
|
40
|
+
for (const path of Object.keys(spec.paths)) {
|
|
41
|
+
for (const method of Object.keys(spec.paths[path])) {
|
|
42
|
+
/* istanbul ignore else */
|
|
43
|
+
if (isClassDeprecated) {
|
|
44
|
+
spec.paths[path][method].deprecated = true;
|
|
45
|
+
}
|
|
46
|
+
/* istanbul ignore else */
|
|
47
|
+
if (classTags) {
|
|
48
|
+
if (spec.paths[path][method].tags &&
|
|
49
|
+
spec.paths[path][method].tags.length) {
|
|
50
|
+
spec.paths[path][method].tags = spec.paths[path][method].tags.concat(classTags.tags);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
spec.paths[path][method].tags = classTags.tags;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
let endpoints = (_a = core_1.MetadataInspector.getAllMethodMetadata(keys_1.OAI3Keys.METHODS_KEY, constructor.prototype), (_a !== null && _a !== void 0 ? _a : {}));
|
|
60
|
+
endpoints = core_1.DecoratorFactory.cloneDeep(endpoints);
|
|
36
61
|
for (const op in endpoints) {
|
|
37
62
|
debug(' processing method %s', op);
|
|
38
63
|
const endpoint = endpoints[op];
|
|
39
64
|
const verb = endpoint.verb;
|
|
40
65
|
const path = endpoint.path;
|
|
66
|
+
const isMethodDeprecated = core_1.MetadataInspector.getMethodMetadata(keys_1.OAI3Keys.DEPRECATED_METHOD_KEY, constructor.prototype, op);
|
|
67
|
+
if (isMethodDeprecated) {
|
|
68
|
+
debug(' using method-level deprecation via @deprecated()');
|
|
69
|
+
}
|
|
70
|
+
const methodTags = core_1.MetadataInspector.getMethodMetadata(keys_1.OAI3Keys.TAGS_METHOD_KEY, constructor.prototype, op);
|
|
71
|
+
if (methodTags) {
|
|
72
|
+
debug(' using method-level tags via @oas.tags()');
|
|
73
|
+
}
|
|
41
74
|
let endpointName = '';
|
|
42
75
|
/* istanbul ignore if */
|
|
43
76
|
if (debug.enabled) {
|
|
@@ -58,23 +91,39 @@ function resolveControllerSpec(constructor) {
|
|
|
58
91
|
};
|
|
59
92
|
endpoint.spec = operationSpec;
|
|
60
93
|
}
|
|
94
|
+
if (classTags && !operationSpec.tags) {
|
|
95
|
+
operationSpec.tags = classTags.tags;
|
|
96
|
+
}
|
|
97
|
+
if (methodTags) {
|
|
98
|
+
if (operationSpec.tags && operationSpec.tags.length) {
|
|
99
|
+
operationSpec.tags = operationSpec.tags.concat(methodTags.tags);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
operationSpec.tags = methodTags.tags;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
61
105
|
debug(' operation for method %s: %j', op, endpoint);
|
|
62
106
|
debug(' spec responses for method %s: %o', op, operationSpec.responses);
|
|
107
|
+
// Prescedence: method decorator > class decorator > operationSpec > undefined
|
|
108
|
+
const deprecationSpec = (_c = (_b = (isMethodDeprecated !== null && isMethodDeprecated !== void 0 ? isMethodDeprecated : isClassDeprecated), (_b !== null && _b !== void 0 ? _b : operationSpec.deprecated)), (_c !== null && _c !== void 0 ? _c : false));
|
|
109
|
+
if (deprecationSpec) {
|
|
110
|
+
operationSpec.deprecated = true;
|
|
111
|
+
}
|
|
63
112
|
for (const code in operationSpec.responses) {
|
|
64
113
|
const responseObject = operationSpec.responses[code];
|
|
65
114
|
if (types_1.isReferenceObject(responseObject))
|
|
66
115
|
continue;
|
|
67
|
-
const content = (
|
|
116
|
+
const content = (_d = responseObject.content, (_d !== null && _d !== void 0 ? _d : {}));
|
|
68
117
|
for (const c in content) {
|
|
69
118
|
debug(' processing response code %s with content-type %', code, c);
|
|
70
119
|
processSchemaExtensions(spec, content[c].schema);
|
|
71
120
|
}
|
|
72
121
|
}
|
|
73
122
|
debug(' processing parameters for method %s', op);
|
|
74
|
-
let params =
|
|
123
|
+
let params = core_1.MetadataInspector.getAllParameterMetadata(keys_1.OAI3Keys.PARAMETERS_KEY, constructor.prototype, op);
|
|
75
124
|
debug(' parameters for method %s: %j', op, params);
|
|
76
125
|
if (params != null) {
|
|
77
|
-
params =
|
|
126
|
+
params = core_1.DecoratorFactory.cloneDeep(params);
|
|
78
127
|
/**
|
|
79
128
|
* If a controller method uses dependency injection, the parameters
|
|
80
129
|
* might be sparse. For example,
|
|
@@ -98,7 +147,7 @@ function resolveControllerSpec(constructor) {
|
|
|
98
147
|
});
|
|
99
148
|
}
|
|
100
149
|
debug(' processing requestBody for method %s', op);
|
|
101
|
-
let requestBodies =
|
|
150
|
+
let requestBodies = core_1.MetadataInspector.getAllParameterMetadata(keys_1.OAI3Keys.REQUEST_BODY_KEY, constructor.prototype, op);
|
|
102
151
|
if (requestBodies != null)
|
|
103
152
|
requestBodies = requestBodies.filter(p => p != null);
|
|
104
153
|
let requestBody;
|
|
@@ -107,8 +156,10 @@ function resolveControllerSpec(constructor) {
|
|
|
107
156
|
throw new Error('An operation should only have one parameter decorated by @requestBody');
|
|
108
157
|
requestBody = requestBodies[0];
|
|
109
158
|
debug(' requestBody for method %s: %j', op, requestBody);
|
|
159
|
+
/* istanbul ignore else */
|
|
110
160
|
if (requestBody) {
|
|
111
161
|
operationSpec.requestBody = requestBody;
|
|
162
|
+
/* istanbul ignore else */
|
|
112
163
|
const content = requestBody.content || {};
|
|
113
164
|
for (const mediaType in content) {
|
|
114
165
|
processSchemaExtensions(spec, content[mediaType].schema);
|
|
@@ -137,9 +188,9 @@ function resolveControllerSpec(constructor) {
|
|
|
137
188
|
debug(` adding ${endpointName}`, operationSpec);
|
|
138
189
|
spec.paths[path][verb] = operationSpec;
|
|
139
190
|
debug(` inferring schema object for method %s`, op);
|
|
140
|
-
const opMetadata =
|
|
191
|
+
const opMetadata = core_1.MetadataInspector.getDesignTypeForMethod(constructor.prototype, op);
|
|
141
192
|
const paramTypes = opMetadata.parameterTypes;
|
|
142
|
-
const isComplexType = (ctor) => !lodash_1.
|
|
193
|
+
const isComplexType = (ctor) => !lodash_1.includes([String, Number, Boolean, Array, Object], ctor);
|
|
143
194
|
for (const p of paramTypes) {
|
|
144
195
|
if (isComplexType(p)) {
|
|
145
196
|
generateOpenAPISchema(spec, p);
|
|
@@ -148,6 +199,7 @@ function resolveControllerSpec(constructor) {
|
|
|
148
199
|
}
|
|
149
200
|
return spec;
|
|
150
201
|
}
|
|
202
|
+
const SCHEMA_ARR_KEYS = ['allOf', 'anyOf', 'oneOf'];
|
|
151
203
|
/**
|
|
152
204
|
* Resolve the x-ts-type in the schema object
|
|
153
205
|
* @param spec - Controller spec
|
|
@@ -159,25 +211,52 @@ function processSchemaExtensions(spec, schema) {
|
|
|
159
211
|
return;
|
|
160
212
|
assignRelatedSchemas(spec, schema.definitions);
|
|
161
213
|
delete schema.definitions;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
generateOpenAPISchema(spec, tsType);
|
|
170
|
-
// We don't want a Function type in the final spec.
|
|
171
|
-
delete schema[exports.TS_TYPE_KEY];
|
|
172
|
-
return;
|
|
214
|
+
/**
|
|
215
|
+
* check if we have been provided a `not`
|
|
216
|
+
* `not` is valid in many cases- here we're checking for
|
|
217
|
+
* `not: { schema: {'x-ts-type': SomeModel }}
|
|
218
|
+
*/
|
|
219
|
+
if (schema.not) {
|
|
220
|
+
processSchemaExtensions(spec, schema.not);
|
|
173
221
|
}
|
|
174
|
-
|
|
175
|
-
|
|
222
|
+
/**
|
|
223
|
+
* check for schema.allOf, schema.oneOf, schema.anyOf arrays first.
|
|
224
|
+
* You cannot provide BOTH a defnintion AND one of these keywords.
|
|
225
|
+
*/
|
|
226
|
+
/* istanbul ignore else */
|
|
227
|
+
const hasOwn = (prop) => { var _a; return (_a = schema) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(prop); };
|
|
228
|
+
if (SCHEMA_ARR_KEYS.some(k => hasOwn(k))) {
|
|
229
|
+
SCHEMA_ARR_KEYS.forEach((k) => {
|
|
230
|
+
var _a;
|
|
231
|
+
/* istanbul ignore else */
|
|
232
|
+
if (((_a = schema) === null || _a === void 0 ? void 0 : _a[k]) && Array.isArray(schema[k])) {
|
|
233
|
+
schema[k].forEach((r) => {
|
|
234
|
+
processSchemaExtensions(spec, r);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
176
238
|
}
|
|
177
|
-
else
|
|
178
|
-
if (schema
|
|
179
|
-
|
|
180
|
-
|
|
239
|
+
else {
|
|
240
|
+
if (types_1.isReferenceObject(schema))
|
|
241
|
+
return;
|
|
242
|
+
const tsType = schema[exports.TS_TYPE_KEY];
|
|
243
|
+
debug(' %s => %o', exports.TS_TYPE_KEY, tsType);
|
|
244
|
+
if (tsType) {
|
|
245
|
+
schema = generate_schema_1.resolveSchema(tsType, schema);
|
|
246
|
+
if (schema.$ref)
|
|
247
|
+
generateOpenAPISchema(spec, tsType);
|
|
248
|
+
// We don't want a Function type in the final spec.
|
|
249
|
+
delete schema[exports.TS_TYPE_KEY];
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (schema.type === 'array') {
|
|
253
|
+
processSchemaExtensions(spec, schema.items);
|
|
254
|
+
}
|
|
255
|
+
else if (schema.type === 'object') {
|
|
256
|
+
if (schema.properties) {
|
|
257
|
+
for (const p in schema.properties) {
|
|
258
|
+
processSchemaExtensions(spec, schema.properties[p]);
|
|
259
|
+
}
|
|
181
260
|
}
|
|
182
261
|
}
|
|
183
262
|
}
|
|
@@ -236,10 +315,10 @@ function assignRelatedSchemas(spec, definitions) {
|
|
|
236
315
|
* @param constructor - Controller class
|
|
237
316
|
*/
|
|
238
317
|
function getControllerSpec(constructor) {
|
|
239
|
-
let spec =
|
|
318
|
+
let spec = core_1.MetadataInspector.getClassMetadata(keys_1.OAI3Keys.CONTROLLER_SPEC_KEY, constructor, { ownMetadataOnly: true });
|
|
240
319
|
if (!spec) {
|
|
241
320
|
spec = resolveControllerSpec(constructor);
|
|
242
|
-
|
|
321
|
+
core_1.MetadataInspector.defineMetadata(keys_1.OAI3Keys.CONTROLLER_SPEC_KEY.key, spec, constructor);
|
|
243
322
|
}
|
|
244
323
|
return spec;
|
|
245
324
|
}
|
|
@@ -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
|
|
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;AACnE,6EAI0C;AAC1C,mCAAgC;AAChC,uDAAgD;AAChD,qDAA+D;AAC/D,iCAAgC;AAChC,mCAaiB;AAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4CAA4C,CAAC,CAAC;AA8BhE,QAAA,WAAW,GAAG,WAAW,CAAC;AAEvC;;;GAGG;AACH,SAAS,qBAAqB,CAAC,WAAqB;;IAClD,KAAK,CAAC,mDAAmD,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAE7E,IAAI,IAAI,GAAG,wBAAiB,CAAC,gBAAgB,CAC3C,eAAQ,CAAC,SAAS,EAClB,WAAW,CACZ,CAAC;IACF,IAAI,IAAI,EAAE;QACR,KAAK,CAAC,6CAA6C,EAAE,IAAI,CAAC,CAAC;QAC3D,IAAI,GAAG,uBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KACzC;SAAM;QACL,IAAI,GAAG,EAAC,KAAK,EAAE,EAAE,EAAC,CAAC;KACpB;IAED,MAAM,iBAAiB,GAAG,wBAAiB,CAAC,gBAAgB,CAC1D,eAAQ,CAAC,oBAAoB,EAC7B,WAAW,CACZ,CAAC;IAEF,IAAI,iBAAiB,EAAE;QACrB,KAAK,CAAC,mCAAmC,CAAC,CAAC;KAC5C;IACD,MAAM,SAAS,GAAG,wBAAiB,CAAC,gBAAgB,CAClD,eAAQ,CAAC,cAAc,EACvB,WAAW,CACZ,CAAC;IAEF,IAAI,SAAS,EAAE;QACb,KAAK,CAAC,iCAAiC,CAAC,CAAC;KAC1C;IAED,IAAI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AC5B,WAAW,EACX,EAAC,eAAe,EAAE,IAAI,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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks an api path as deprecated. When applied to a class, this decorator
|
|
3
|
+
* marks all paths as deprecated.
|
|
4
|
+
*
|
|
5
|
+
* You can optionally mark all controllers in a class as deprecated, but use
|
|
6
|
+
* `@deprecated(false)` on a specific method to ensure it is not marked
|
|
7
|
+
* as deprecated in the specification.
|
|
8
|
+
*
|
|
9
|
+
* @param isDeprecated - whether or not the path should be marked as deprecated.
|
|
10
|
+
* This is useful for marking a class as deprecated, but a method as
|
|
11
|
+
* not deprecated.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @oas.deprecated()
|
|
16
|
+
* class MyController {
|
|
17
|
+
* @get('/greet')
|
|
18
|
+
* public async function greet() {
|
|
19
|
+
* return 'Hello, World!'
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* @get('/greet-v2')
|
|
23
|
+
* @oas.deprecated(false)
|
|
24
|
+
* public async function greetV2() {
|
|
25
|
+
* return 'Hello, World!'
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* class MyOtherController {
|
|
30
|
+
* @get('/echo')
|
|
31
|
+
* public async function echo() {
|
|
32
|
+
* return 'Echo!'
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function deprecated(isDeprecated?: boolean): (target: any, method?: string | undefined, methodDescriptor?: TypedPropertyDescriptor<any> | undefined) => any;
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
const debug = require('debug')('loopback:openapi3:metadata:controller-spec:deprecated');
|
|
10
|
+
/**
|
|
11
|
+
* Marks an api path as deprecated. When applied to a class, this decorator
|
|
12
|
+
* marks all paths as deprecated.
|
|
13
|
+
*
|
|
14
|
+
* You can optionally mark all controllers in a class as deprecated, but use
|
|
15
|
+
* `@deprecated(false)` on a specific method to ensure it is not marked
|
|
16
|
+
* as deprecated in the specification.
|
|
17
|
+
*
|
|
18
|
+
* @param isDeprecated - whether or not the path should be marked as deprecated.
|
|
19
|
+
* This is useful for marking a class as deprecated, but a method as
|
|
20
|
+
* not deprecated.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* @oas.deprecated()
|
|
25
|
+
* class MyController {
|
|
26
|
+
* @get('/greet')
|
|
27
|
+
* public async function greet() {
|
|
28
|
+
* return 'Hello, World!'
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* @get('/greet-v2')
|
|
32
|
+
* @oas.deprecated(false)
|
|
33
|
+
* public async function greetV2() {
|
|
34
|
+
* return 'Hello, World!'
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* class MyOtherController {
|
|
39
|
+
* @get('/echo')
|
|
40
|
+
* public async function echo() {
|
|
41
|
+
* return 'Echo!'
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function deprecated(isDeprecated = true) {
|
|
47
|
+
return function deprecatedDecoratorForClassOrMethod(
|
|
48
|
+
// Class or a prototype
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
target, method,
|
|
51
|
+
// Use `any` to for `TypedPropertyDescriptor`
|
|
52
|
+
// See https://github.com/strongloop/loopback-next/pull/2704
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
methodDescriptor) {
|
|
55
|
+
debug(target, method, methodDescriptor);
|
|
56
|
+
if (method && methodDescriptor) {
|
|
57
|
+
// Method
|
|
58
|
+
return core_1.MethodDecoratorFactory.createDecorator(keys_1.OAI3Keys.DEPRECATED_METHOD_KEY, isDeprecated, { decoratorName: '@oas.deprecated' })(target, method, methodDescriptor);
|
|
59
|
+
}
|
|
60
|
+
else if (typeof target === 'function' && !method && !methodDescriptor) {
|
|
61
|
+
// Class
|
|
62
|
+
return core_1.ClassDecoratorFactory.createDecorator(keys_1.OAI3Keys.DEPRECATED_CLASS_KEY, isDeprecated, { decoratorName: '@oas.deprecated' })(target);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error('@oas.deprecated cannot be used on a property: ' +
|
|
66
|
+
core_1.DecoratorFactory.getTargetName(target, method, methodDescriptor));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.deprecated = deprecated;
|
|
71
|
+
//# sourceMappingURL=deprecated.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecated.decorator.js","sourceRoot":"","sources":["../../src/decorators/deprecated.decorator.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAIwB;AACxB,kCAAiC;AAEjC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAC5B,uDAAuD,CACxD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,SAAgB,UAAU,CAAC,YAAY,GAAG,IAAI;IAC5C,OAAO,SAAS,mCAAmC;IACjD,uBAAuB;IACvB,8DAA8D;IAC9D,MAAW,EACX,MAAe;IACf,6CAA6C;IAC7C,4DAA4D;IAC5D,8DAA8D;IAC9D,gBAA+C;QAE/C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAExC,IAAI,MAAM,IAAI,gBAAgB,EAAE;YAC9B,SAAS;YACT,OAAO,6BAAsB,CAAC,eAAe,CAC3C,eAAQ,CAAC,qBAAqB,EAC9B,YAAY,EACZ,EAAC,aAAa,EAAE,iBAAiB,EAAC,CACnC,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,oBAAoB,EAC7B,YAAY,EACZ,EAAC,aAAa,EAAE,iBAAiB,EAAC,CACnC,CAAC,MAAM,CAAC,CAAC;SACX;aAAM;YACL,MAAM,IAAI,KAAK,CACb,gDAAgD;gBAC9C,uBAAgB,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CACnE,CAAC;SACH;IACH,CAAC,CAAC;AACJ,CAAC;AAlCD,gCAkCC"}
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
export * from './api.decorator';
|
|
2
|
+
export * from './deprecated.decorator';
|
|
2
3
|
export * from './operation.decorator';
|
|
3
4
|
export * from './parameter.decorator';
|
|
4
5
|
export * from './request-body.decorator';
|
|
6
|
+
import { api } from './api.decorator';
|
|
7
|
+
import { deprecated } from './deprecated.decorator';
|
|
8
|
+
import { del, get, operation, patch, post, put } from './operation.decorator';
|
|
9
|
+
import { param } from './parameter.decorator';
|
|
10
|
+
import { requestBody } from './request-body.decorator';
|
|
11
|
+
import { tags } from './tags.decorator';
|
|
12
|
+
export declare const oas: {
|
|
13
|
+
api: typeof api;
|
|
14
|
+
operation: typeof operation;
|
|
15
|
+
get: typeof get;
|
|
16
|
+
post: typeof post;
|
|
17
|
+
del: typeof del;
|
|
18
|
+
patch: typeof patch;
|
|
19
|
+
put: typeof put;
|
|
20
|
+
param: typeof param;
|
|
21
|
+
requestBody: typeof requestBody;
|
|
22
|
+
deprecated: typeof deprecated;
|
|
23
|
+
tags: typeof tags;
|
|
24
|
+
};
|
package/dist/decorators/index.js
CHANGED
|
@@ -8,7 +8,31 @@ function __export(m) {
|
|
|
8
8
|
}
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
__export(require("./api.decorator"));
|
|
11
|
+
__export(require("./deprecated.decorator"));
|
|
11
12
|
__export(require("./operation.decorator"));
|
|
12
13
|
__export(require("./parameter.decorator"));
|
|
13
14
|
__export(require("./request-body.decorator"));
|
|
15
|
+
const api_decorator_1 = require("./api.decorator");
|
|
16
|
+
const deprecated_decorator_1 = require("./deprecated.decorator");
|
|
17
|
+
const operation_decorator_1 = require("./operation.decorator");
|
|
18
|
+
const parameter_decorator_1 = require("./parameter.decorator");
|
|
19
|
+
const request_body_decorator_1 = require("./request-body.decorator");
|
|
20
|
+
const tags_decorator_1 = require("./tags.decorator");
|
|
21
|
+
exports.oas = {
|
|
22
|
+
api: api_decorator_1.api,
|
|
23
|
+
operation: operation_decorator_1.operation,
|
|
24
|
+
// methods
|
|
25
|
+
get: operation_decorator_1.get,
|
|
26
|
+
post: operation_decorator_1.post,
|
|
27
|
+
del: operation_decorator_1.del,
|
|
28
|
+
patch: operation_decorator_1.patch,
|
|
29
|
+
put: operation_decorator_1.put,
|
|
30
|
+
//param
|
|
31
|
+
param: parameter_decorator_1.param,
|
|
32
|
+
// request body
|
|
33
|
+
requestBody: request_body_decorator_1.requestBody,
|
|
34
|
+
// oas convenience decorators
|
|
35
|
+
deprecated: deprecated_decorator_1.deprecated,
|
|
36
|
+
tags: tags_decorator_1.tags,
|
|
37
|
+
};
|
|
14
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,qCAAgC;AAChC,2CAAsC;AACtC,2CAAsC;AACtC,8CAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,qCAAgC;AAChC,4CAAuC;AACvC,2CAAsC;AACtC,2CAAsC;AACtC,8CAAyC;AAEzC,mDAAoC;AACpC,iEAAkD;AAClD,+DAA4E;AAC5E,+DAA4C;AAC5C,qEAAqD;AACrD,qDAAsC;AAEzB,QAAA,GAAG,GAAG;IACjB,GAAG,EAAH,mBAAG;IACH,SAAS,EAAT,+BAAS;IAET,UAAU;IACV,GAAG,EAAH,yBAAG;IACH,IAAI,EAAJ,0BAAI;IACJ,GAAG,EAAH,yBAAG;IACH,KAAK,EAAL,2BAAK;IACL,GAAG,EAAH,yBAAG;IAEH,OAAO;IACP,KAAK,EAAL,2BAAK;IAEL,eAAe;IACf,WAAW,EAAX,oCAAW;IAEX,6BAA6B;IAC7B,UAAU,EAAV,iCAAU;IACV,IAAI,EAAJ,qBAAI;CACL,CAAC"}
|
|
@@ -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"}
|