serverless-openapi-documenter 0.0.110 → 0.0.112
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
CHANGED
|
@@ -1009,18 +1009,18 @@ I am making use of https://www.npmjs.com/package/@redocly/openapi-core, which I
|
|
|
1009
1009
|
|
|
1010
1010
|
I have configured the validator to use these Rules:
|
|
1011
1011
|
|
|
1012
|
-
- [
|
|
1013
|
-
- [path-parameters-defined](https://redocly.com/docs/cli/rules/path-parameters-defined
|
|
1014
|
-
- [operation-2xx-response](https://redocly.com/docs/cli/rules/operation-2xx-response
|
|
1015
|
-
- [operation-4xx-response](https://redocly.com/docs/cli/rules/operation-4xx-response
|
|
1016
|
-
- [operation-operationId-unique](https://redocly.com/docs/cli/rules/operation-
|
|
1017
|
-
- [path-declaration-must-exist](https://redocly.com/docs/cli/rules/path-declaration-must-exist
|
|
1012
|
+
- [struct](https://redocly.com/docs/cli/rules/oas/struct)
|
|
1013
|
+
- [path-parameters-defined](https://redocly.com/docs/cli/rules/oas/path-parameters-defined)
|
|
1014
|
+
- [operation-2xx-response](https://redocly.com/docs/cli/rules/oas/operation-2xx-response)
|
|
1015
|
+
- [operation-4xx-response](https://redocly.com/docs/cli/rules/oas/operation-4xx-response)
|
|
1016
|
+
- [operation-operationId-unique](https://redocly.com/docs/cli/rules/oas/operation-operationId-unique)
|
|
1017
|
+
- [path-declaration-must-exist](https://redocly.com/docs/cli/rules/oas/path-declaration-must-exist)
|
|
1018
1018
|
|
|
1019
1019
|
However, you can configure your own rules from the [ruleset available on the Redocly site](https://redocly.com/docs/cli/rules/built-in-rules/). To do this, you will need to create a `redocly.json` file within an `options` folder. The file should look like:
|
|
1020
1020
|
|
|
1021
1021
|
```json
|
|
1022
1022
|
{
|
|
1023
|
-
"
|
|
1023
|
+
"struct": "error",
|
|
1024
1024
|
"path-parameters-defined": "error",
|
|
1025
1025
|
"operation-2xx-response": "error",
|
|
1026
1026
|
"operation-4xx-response": "error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-openapi-documenter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.112",
|
|
4
4
|
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"chalk": "^4.1.2",
|
|
51
51
|
"js-yaml": "^4.1.0",
|
|
52
52
|
"json-schema-for-openapi": "^0.5.0",
|
|
53
|
-
"lodash.isequal": "^4.5.0",
|
|
54
53
|
"openapi-to-postmanv2": "^5.0.0",
|
|
55
54
|
"uuid": "^11.1.0"
|
|
56
55
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const isEqual = require("node:util").isDeepStrictEqual;
|
|
3
4
|
const path = require("path");
|
|
4
5
|
|
|
5
6
|
const {
|
|
@@ -8,7 +9,6 @@ const {
|
|
|
8
9
|
stringifyYaml,
|
|
9
10
|
createConfig,
|
|
10
11
|
} = require("@redocly/openapi-core");
|
|
11
|
-
const isEqual = require("lodash.isequal");
|
|
12
12
|
const { v4: uuid } = require("uuid");
|
|
13
13
|
|
|
14
14
|
const SchemaHandler = require("./schemaHandler");
|
|
@@ -39,7 +39,11 @@ class DefinitionGenerator {
|
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
this.schemaHandler = new SchemaHandler(
|
|
42
|
+
this.schemaHandler = new SchemaHandler(
|
|
43
|
+
serverless,
|
|
44
|
+
this.openAPI,
|
|
45
|
+
this.logger
|
|
46
|
+
);
|
|
43
47
|
|
|
44
48
|
this.operationIdMap = {};
|
|
45
49
|
this.functionMap = {};
|
|
@@ -81,7 +85,7 @@ class DefinitionGenerator {
|
|
|
81
85
|
this.REDOCLY_RULES = require(path.resolve("options", "redocly.json"));
|
|
82
86
|
} catch (err) {
|
|
83
87
|
this.REDOCLY_RULES = {
|
|
84
|
-
|
|
88
|
+
struct: "error",
|
|
85
89
|
"path-parameters-defined": "error",
|
|
86
90
|
"operation-2xx-response": "error",
|
|
87
91
|
"operation-4xx-response": "error",
|
package/src/schemaHandler.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const isEqual = require("node:util").isDeepStrictEqual;
|
|
3
4
|
const path = require("path");
|
|
4
5
|
|
|
5
6
|
const $RefParser = require("@apidevtools/json-schema-ref-parser");
|
|
6
7
|
const SchemaConvertor = require("json-schema-for-openapi");
|
|
7
|
-
const isEqual = require("lodash.isequal");
|
|
8
8
|
const { v4: uuid } = require("uuid");
|
|
9
9
|
|
|
10
10
|
class SchemaHandler {
|
|
11
|
-
constructor(serverless, openAPI) {
|
|
11
|
+
constructor(serverless, openAPI, logger) {
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
|
|
12
14
|
this.apiGatewayModels =
|
|
13
15
|
serverless.service?.provider?.apiGateway?.request?.schemas || {};
|
|
14
16
|
this.documentation = serverless.service.custom.documentation;
|
|
@@ -19,6 +21,12 @@ class SchemaHandler {
|
|
|
19
21
|
this.__standardiseModels();
|
|
20
22
|
|
|
21
23
|
try {
|
|
24
|
+
this.logger.verbose(
|
|
25
|
+
`Trying to resolve Ref-Parser config from: ${path.resolve(
|
|
26
|
+
"options",
|
|
27
|
+
"ref-parser.js"
|
|
28
|
+
)}`
|
|
29
|
+
);
|
|
22
30
|
this.refParserOptions = require(path.resolve("options", "ref-parser.js"));
|
|
23
31
|
} catch (err) {
|
|
24
32
|
this.refParserOptions = {};
|
|
@@ -63,6 +71,7 @@ class SchemaHandler {
|
|
|
63
71
|
const modelName = model.name;
|
|
64
72
|
const modelSchema = model.schema;
|
|
65
73
|
|
|
74
|
+
this.logger.verbose(`dereferencing model: ${model.name}`);
|
|
66
75
|
const dereferencedSchema = await this.__dereferenceSchema(
|
|
67
76
|
modelSchema
|
|
68
77
|
).catch((err) => {
|
|
@@ -76,6 +85,7 @@ class SchemaHandler {
|
|
|
76
85
|
return modelSchema;
|
|
77
86
|
});
|
|
78
87
|
|
|
88
|
+
this.logger.verbose(`convering model: ${model.name}`);
|
|
79
89
|
const convertedSchemas = SchemaConvertor.convert(
|
|
80
90
|
dereferencedSchema,
|
|
81
91
|
modelName
|