serverless-openapi-documenter 0.0.91 → 0.0.93
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/package.json +1 -1
- package/src/definitionGenerator.js +31 -9
package/package.json
CHANGED
|
@@ -154,10 +154,16 @@ class DefinitionGenerator {
|
|
|
154
154
|
Object.assign(info, { license: licenseObj });
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
for (const key of Object.keys(documentation)) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
// for (const key of Object.keys(documentation)) {
|
|
158
|
+
// if (/^[x\-]/i.test(key)) {
|
|
159
|
+
// Object.assign(info, { [key]: documentation[key] });
|
|
160
|
+
// }
|
|
161
|
+
// }
|
|
162
|
+
|
|
163
|
+
const extendedSpec = this.extendSpecification(documentation);
|
|
164
|
+
|
|
165
|
+
if (Object.keys(extendedSpec).length) {
|
|
166
|
+
Object.assign(info, extendedSpec);
|
|
161
167
|
}
|
|
162
168
|
|
|
163
169
|
Object.assign(this.openAPI, { info });
|
|
@@ -419,6 +425,12 @@ class DefinitionGenerator {
|
|
|
419
425
|
obj.servers = servers;
|
|
420
426
|
}
|
|
421
427
|
|
|
428
|
+
const extendedSpec = this.extendSpecification(documentation);
|
|
429
|
+
|
|
430
|
+
if (Object.keys(extendedSpec).length) {
|
|
431
|
+
Object.assign(obj, extendedSpec);
|
|
432
|
+
}
|
|
433
|
+
|
|
422
434
|
return { [method.toLowerCase()]: obj };
|
|
423
435
|
}
|
|
424
436
|
|
|
@@ -937,6 +949,17 @@ class DefinitionGenerator {
|
|
|
937
949
|
}
|
|
938
950
|
}
|
|
939
951
|
|
|
952
|
+
extendSpecification(spec) {
|
|
953
|
+
const obj = {};
|
|
954
|
+
for (const key of Object.keys(spec)) {
|
|
955
|
+
if (/^[x\-]/i.test(key)) {
|
|
956
|
+
Object.assign(obj, { [key]: spec[key] });
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
return obj;
|
|
961
|
+
}
|
|
962
|
+
|
|
940
963
|
getHTTPFunctions() {
|
|
941
964
|
const isHttpFunction = (funcType) => {
|
|
942
965
|
const keys = Object.keys(funcType);
|
|
@@ -946,6 +969,7 @@ class DefinitionGenerator {
|
|
|
946
969
|
)
|
|
947
970
|
return true;
|
|
948
971
|
};
|
|
972
|
+
|
|
949
973
|
const functionNames = this.serverless.service.getAllFunctions();
|
|
950
974
|
|
|
951
975
|
return functionNames
|
|
@@ -957,16 +981,14 @@ class DefinitionGenerator {
|
|
|
957
981
|
})
|
|
958
982
|
.map((functionType) => {
|
|
959
983
|
const event = functionType.events.filter(isHttpFunction);
|
|
960
|
-
const
|
|
961
|
-
`${this.serverless.service.service}-${this.serverless.service.provider.stage}-`
|
|
962
|
-
)[1];
|
|
984
|
+
const operationName = functionType.name.split("-").slice(-1).pop();
|
|
963
985
|
|
|
964
986
|
Object.assign(this.functionMap, {
|
|
965
|
-
[
|
|
987
|
+
[operationName]: [],
|
|
966
988
|
});
|
|
967
989
|
|
|
968
990
|
return {
|
|
969
|
-
operationName:
|
|
991
|
+
operationName: operationName,
|
|
970
992
|
functionInfo: functionType,
|
|
971
993
|
handler: functionType.handler,
|
|
972
994
|
name: functionType.name,
|