serverless-openapi-documenter 0.0.90 → 0.0.92
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/README.md +9 -0
- package/package.json +9 -6
- package/src/definitionGenerator.js +4 -5
package/README.md
CHANGED
|
@@ -942,6 +942,15 @@ This will set the `Cache-Control` Response Header to have a value of "no-store"
|
|
|
942
942
|
|
|
943
943
|
Validation for the OpenAPI Description is now (as of 0.0.90) done by [Redocly](https://redocly.com/). This is a slightly less opinionated validator for an OpenAPI Description, it should result in less errors around "YAML Anchors". It's also a maintained library, and has support for OpenAPI 3.1.0 which I hope to be able to support very soon.
|
|
944
944
|
|
|
945
|
+
I have configured the validator to use these Rules:
|
|
946
|
+
|
|
947
|
+
* [spec](https://redocly.com/docs/cli/rules/spec/)
|
|
948
|
+
* [path-parameters-defined](https://redocly.com/docs/cli/rules/path-parameters-defined/)
|
|
949
|
+
* [operation-2xx-response](https://redocly.com/docs/cli/rules/operation-2xx-response/)
|
|
950
|
+
* [operation-4xx-response](https://redocly.com/docs/cli/rules/operation-4xx-response/)
|
|
951
|
+
* [operation-operationId-unique](https://redocly.com/docs/cli/rules/operation-operationid-unique/)
|
|
952
|
+
* [path-declaration-must-exist](https://redocly.com/docs/cli/rules/path-declaration-must-exist/)
|
|
953
|
+
|
|
945
954
|
I am making use of https://www.npmjs.com/package/@redocly/openapi-core, which I have been warned is likely to change. If you notice anything going wrong with validation of your OpenAPI Description, feel free to open an issue here. I make active use of this library, so will hopefully come across those issues too.
|
|
946
955
|
|
|
947
956
|
## Example configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-openapi-documenter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.92",
|
|
4
4
|
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"Postman Collections",
|
|
21
21
|
"AWS",
|
|
22
22
|
"AWS APIGateway",
|
|
23
|
-
"Api Gateway"
|
|
23
|
+
"Api Gateway",
|
|
24
|
+
"APIGateway",
|
|
25
|
+
"AWSAPIGateway",
|
|
26
|
+
"Serverless OpenAPI"
|
|
24
27
|
],
|
|
25
28
|
"scripts": {
|
|
26
29
|
"test": "mocha --config './test/.mocharc.js'"
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
"@redocly/openapi-core": "^1.2.0",
|
|
42
45
|
"chalk": "^4.1.2",
|
|
43
46
|
"js-yaml": "^4.1.0",
|
|
44
|
-
"json-schema-for-openapi": "^0.4.
|
|
47
|
+
"json-schema-for-openapi": "^0.4.3",
|
|
45
48
|
"lodash.isequal": "^4.5.0",
|
|
46
49
|
"openapi-to-postmanv2": "^4.18.0",
|
|
47
50
|
"swagger2openapi": "^7.0.8",
|
|
@@ -51,9 +54,9 @@
|
|
|
51
54
|
"node": ">=14"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
|
-
"chai": "^4.3.
|
|
57
|
+
"chai": "^4.3.10",
|
|
55
58
|
"mocha": "^10.2.0",
|
|
56
|
-
"nock": "^13.
|
|
57
|
-
"sinon": "^
|
|
59
|
+
"nock": "^13.4.0",
|
|
60
|
+
"sinon": "^17.0.1"
|
|
58
61
|
}
|
|
59
62
|
}
|
|
@@ -946,6 +946,7 @@ class DefinitionGenerator {
|
|
|
946
946
|
)
|
|
947
947
|
return true;
|
|
948
948
|
};
|
|
949
|
+
|
|
949
950
|
const functionNames = this.serverless.service.getAllFunctions();
|
|
950
951
|
|
|
951
952
|
return functionNames
|
|
@@ -957,16 +958,14 @@ class DefinitionGenerator {
|
|
|
957
958
|
})
|
|
958
959
|
.map((functionType) => {
|
|
959
960
|
const event = functionType.events.filter(isHttpFunction);
|
|
960
|
-
const
|
|
961
|
-
`${this.serverless.service.service}-${this.serverless.service.provider.stage}-`
|
|
962
|
-
)[1];
|
|
961
|
+
const operationName = functionType.name.split("-").slice(-1).pop();
|
|
963
962
|
|
|
964
963
|
Object.assign(this.functionMap, {
|
|
965
|
-
[
|
|
964
|
+
[operationName]: [],
|
|
966
965
|
});
|
|
967
966
|
|
|
968
967
|
return {
|
|
969
|
-
operationName:
|
|
968
|
+
operationName: operationName,
|
|
970
969
|
functionInfo: functionType,
|
|
971
970
|
handler: functionType.handler,
|
|
972
971
|
name: functionType.name,
|