serverless-openapi-documenter 0.0.81 → 0.0.83
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 +1 -2
- package/package.json +1 -1
- package/src/definitionGenerator.js +18 -14
- package/src/openAPIGenerator.js +295 -214
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ Options:
|
|
|
49
49
|
--indent -i File indentation in spaces. Default: 2
|
|
50
50
|
--openApiVersion -a OpenAPI version to generate for. Default: 3.0.0
|
|
51
51
|
--postmanCollection -p Will generate a postman collection (from the generated openAPI documentation), in json only, if passed in. Default postman.json
|
|
52
|
+
--validationWarn -w Warn about validation errors only. Will write the OpenAPI file if generation is successful. Default: false
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
### README Highlighted Reading
|
|
@@ -95,8 +96,6 @@ Options:
|
|
|
95
96
|
| tags[].externalDocs.url | custom.documentation.tags.externalDocumentation.url |
|
|
96
97
|
| tags[].externalDocs.description | custom.documentation.tags.externalDocumentation.description |
|
|
97
98
|
| path[path] | functions.functions.events.[http OR httpApi].path |
|
|
98
|
-
| path[path].summary | functions.functions.summary |
|
|
99
|
-
| path[path].description | functions.functions.description |
|
|
100
99
|
| path[path].servers[].description | functions.functions.servers.description |
|
|
101
100
|
| path[path].servers[].url | functions.functions.servers.url |
|
|
102
101
|
| path[path].[operation] | functions.functions.[http OR httpApi].method |
|
package/package.json
CHANGED
|
@@ -179,11 +179,11 @@ class DefinitionGenerator {
|
|
|
179
179
|
throw err;
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
if (httpFunction.functionInfo?.summary)
|
|
183
|
-
|
|
182
|
+
// if (httpFunction.functionInfo?.summary)
|
|
183
|
+
// path.summary = httpFunction.functionInfo.summary;
|
|
184
184
|
|
|
185
|
-
if (httpFunction.functionInfo?.description)
|
|
186
|
-
|
|
185
|
+
// if (httpFunction.functionInfo?.description)
|
|
186
|
+
// path.description = httpFunction.functionInfo.description;
|
|
187
187
|
|
|
188
188
|
if (httpFunction.functionInfo?.servers) {
|
|
189
189
|
const servers = this.createServers(
|
|
@@ -910,16 +910,20 @@ class DefinitionGenerator {
|
|
|
910
910
|
cleanupLinks() {
|
|
911
911
|
for (const path of Object.keys(this.openAPI.paths)) {
|
|
912
912
|
for (const [name, value] of Object.entries(this.openAPI.paths[path])) {
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
)
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
)
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
|
|
913
|
+
if (
|
|
914
|
+
RegExp(/(get|put|post|delete|options|head|patch|trace)/i).test(name)
|
|
915
|
+
) {
|
|
916
|
+
for (const [statusCode, responseObj] of Object.entries(
|
|
917
|
+
value?.responses
|
|
918
|
+
)) {
|
|
919
|
+
if (responseObj.links) {
|
|
920
|
+
for (const [linkName, linkObj] of Object.entries(
|
|
921
|
+
responseObj.links
|
|
922
|
+
)) {
|
|
923
|
+
const opId = linkObj.operationId;
|
|
924
|
+
if (this.functionMap[opId]) {
|
|
925
|
+
linkObj.operationId = this.functionMap[opId][0];
|
|
926
|
+
}
|
|
923
927
|
}
|
|
924
928
|
}
|
|
925
929
|
}
|
package/src/openAPIGenerator.js
CHANGED
|
@@ -1,251 +1,332 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const fs = require(
|
|
4
|
-
const yaml = require(
|
|
5
|
-
const chalk = require(
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const yaml = require("js-yaml");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
6
|
|
|
7
|
-
const DefinitionGenerator = require(
|
|
8
|
-
const PostmanGenerator = require(
|
|
7
|
+
const DefinitionGenerator = require("./definitionGenerator");
|
|
8
|
+
const PostmanGenerator = require("openapi-to-postmanv2");
|
|
9
9
|
|
|
10
10
|
class OpenAPIGenerator {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
11
|
+
constructor(serverless, options, { log = {} } = {}) {
|
|
12
|
+
this.logOutput = log;
|
|
13
|
+
this.serverless = serverless;
|
|
14
|
+
this.options = options;
|
|
15
|
+
|
|
16
|
+
this.logTypes = {
|
|
17
|
+
NOTICE: "notice",
|
|
18
|
+
DEBUG: "debug",
|
|
19
|
+
ERROR: "error",
|
|
20
|
+
WARNING: "warning",
|
|
21
|
+
INFO: "info",
|
|
22
|
+
VERBOSE: "verbose",
|
|
23
|
+
SUCCESS: "success",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
this.defaultLog = this.logTypes.NOTICE;
|
|
27
|
+
|
|
28
|
+
this.commands = {
|
|
29
|
+
openapi: {
|
|
30
|
+
commands: {
|
|
31
|
+
generate: {
|
|
32
|
+
lifecycleEvents: ["serverless"],
|
|
33
|
+
usage: "Generate OpenAPI v3 Documentation",
|
|
34
|
+
options: {
|
|
35
|
+
output: {
|
|
36
|
+
usage: "Output file location [default: openapi.json|yml]",
|
|
37
|
+
shortcut: "o",
|
|
38
|
+
type: "string",
|
|
39
|
+
},
|
|
40
|
+
format: {
|
|
41
|
+
usage: "OpenAPI file format (yml|json) [default: json]",
|
|
42
|
+
shortcut: "f",
|
|
43
|
+
type: "string",
|
|
44
|
+
},
|
|
45
|
+
indent: {
|
|
46
|
+
usage: "File indentation in spaces [default: 2]",
|
|
47
|
+
shortcut: "i",
|
|
48
|
+
type: "string",
|
|
49
|
+
},
|
|
50
|
+
openApiVersion: {
|
|
51
|
+
usage: "OpenAPI version number [default: 3.0.0]",
|
|
52
|
+
shortcut: "a",
|
|
53
|
+
type: "string",
|
|
54
|
+
},
|
|
55
|
+
postmanCollection: {
|
|
56
|
+
usage:
|
|
57
|
+
"Output a postman collection and attach to OpenApi external documents [default: postman.json if passed]",
|
|
58
|
+
shortcut: "p",
|
|
59
|
+
type: "string",
|
|
60
|
+
},
|
|
61
|
+
validationWarn: {
|
|
62
|
+
usage:
|
|
63
|
+
"Only warn about validation errors of the OpenAPI document, write the file if parsing is successful [default: false]",
|
|
64
|
+
shortcut: "w",
|
|
65
|
+
type: "boolean",
|
|
63
66
|
},
|
|
64
67
|
},
|
|
65
68
|
},
|
|
66
|
-
}
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
this.hooks = {
|
|
74
|
+
"openapi:generate:serverless": this.generate.bind(this),
|
|
75
|
+
};
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
this.customVars = this.serverless.variables.service.custom;
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
const functionEventDocumentationSchema = {
|
|
80
|
+
properties: {
|
|
81
|
+
documentation: {
|
|
82
|
+
type: "object",
|
|
75
83
|
properties: {
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
properties: {
|
|
79
|
-
methodResponses: {
|
|
80
|
-
type: 'array'
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
required: ['methodResponses']
|
|
84
|
+
methodResponses: {
|
|
85
|
+
type: "array",
|
|
84
86
|
},
|
|
85
87
|
},
|
|
88
|
+
required: ["methodResponses"],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
this.serverless.configSchemaHandler.defineCustomProperties({
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: {
|
|
96
|
+
documentation: {
|
|
97
|
+
type: "object",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ["documentation"],
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
this.serverless.configSchemaHandler.defineFunctionEventProperties(
|
|
104
|
+
"aws",
|
|
105
|
+
"http",
|
|
106
|
+
functionEventDocumentationSchema
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
this.serverless.configSchemaHandler.defineFunctionEventProperties(
|
|
110
|
+
"aws",
|
|
111
|
+
"httpApi",
|
|
112
|
+
functionEventDocumentationSchema
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
this.serverless.configSchemaHandler.defineFunctionProperties("aws", {
|
|
116
|
+
properties: {
|
|
117
|
+
summary: { type: "string" },
|
|
118
|
+
servers: { anyOf: [{ type: "object" }, { type: "array" }] },
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
log(str, type = this.defaultLog) {
|
|
124
|
+
switch (this.serverless.version[0]) {
|
|
125
|
+
case "2":
|
|
126
|
+
let colouredString = str;
|
|
127
|
+
if (type === "error") {
|
|
128
|
+
colouredString = chalk.bold.red(`✖ ${str}`);
|
|
129
|
+
} else if (type === "success") {
|
|
130
|
+
colouredString = chalk.bold.green(`✓ ${str}`);
|
|
86
131
|
}
|
|
87
132
|
|
|
88
|
-
this.serverless.
|
|
89
|
-
|
|
90
|
-
properties: {
|
|
91
|
-
documentation: {
|
|
92
|
-
type: 'object'
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
required: ['documentation']
|
|
96
|
-
})
|
|
133
|
+
this.serverless.cli.log(colouredString);
|
|
134
|
+
break;
|
|
97
135
|
|
|
98
|
-
|
|
136
|
+
case "3":
|
|
137
|
+
this.logOutput[type](str);
|
|
138
|
+
break;
|
|
99
139
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
properties: {
|
|
104
|
-
summary: {type: 'string'},
|
|
105
|
-
servers: {anyOf: [{type:'object'}, {type:'array'}]},
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
log(str, type = this.defaultLog) {
|
|
111
|
-
switch(this.serverless.version[0]) {
|
|
112
|
-
case '2':
|
|
113
|
-
let colouredString = str
|
|
114
|
-
if (type === 'error') {
|
|
115
|
-
colouredString = chalk.bold.red(`✖ ${str}`)
|
|
116
|
-
} else if (type === 'success') {
|
|
117
|
-
colouredString = chalk.bold.green(`✓ ${str}`)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
this.serverless.cli.log(colouredString)
|
|
121
|
-
break
|
|
122
|
-
|
|
123
|
-
case '3':
|
|
124
|
-
this.logOutput[type](str)
|
|
125
|
-
break
|
|
126
|
-
|
|
127
|
-
default:
|
|
128
|
-
process.stdout.write(str.join(' '))
|
|
129
|
-
break
|
|
130
|
-
}
|
|
140
|
+
default:
|
|
141
|
+
process.stdout.write(str.join(" "));
|
|
142
|
+
break;
|
|
131
143
|
}
|
|
144
|
+
}
|
|
132
145
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
async generate() {
|
|
147
|
+
this.log(chalk.bold.underline("OpenAPI v3 Document Generation"));
|
|
148
|
+
this.processCliInput();
|
|
136
149
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
})
|
|
150
|
+
const validOpenAPI = await this.generationAndValidation().catch((err) => {
|
|
151
|
+
throw new this.serverless.classes.Error(err);
|
|
152
|
+
});
|
|
141
153
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
let output
|
|
147
|
-
switch (this.config.format.toLowerCase()) {
|
|
148
|
-
case 'json':
|
|
149
|
-
output = JSON.stringify(validOpenAPI, null, this.config.indent);
|
|
150
|
-
break;
|
|
151
|
-
case 'yaml':
|
|
152
|
-
default:
|
|
153
|
-
output = yaml.dump(validOpenAPI, { indent: this.config.indent });
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
fs.writeFileSync(this.config.file, output);
|
|
158
|
-
this.log('OpenAPI v3 Documentation Successfully Written', this.logTypes.SUCCESS)
|
|
159
|
-
} catch (err) {
|
|
160
|
-
this.log(`ERROR: An error was thrown whilst writing the openAPI Documentation`, this.logTypes.ERROR)
|
|
161
|
-
throw new this.serverless.classes.Error(err)
|
|
162
|
-
}
|
|
154
|
+
if (this.config.postmanCollection) {
|
|
155
|
+
this.createPostman(validOpenAPI);
|
|
163
156
|
}
|
|
164
157
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
await generator.validate()
|
|
175
|
-
.catch(err => {
|
|
176
|
-
this.log(`ERROR: An error was thrown validating the OpenAPI v3 documentation`, this.logTypes.ERROR)
|
|
177
|
-
this.validationErrorDetails(err)
|
|
178
|
-
throw new this.serverless.classes.Error(err)
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.log('OpenAPI v3 Documentation Successfully Generated', this.logTypes.SUCCESS)
|
|
183
|
-
|
|
184
|
-
return generator.openAPI
|
|
158
|
+
let output;
|
|
159
|
+
switch (this.config.format.toLowerCase()) {
|
|
160
|
+
case "json":
|
|
161
|
+
output = JSON.stringify(validOpenAPI, null, this.config.indent);
|
|
162
|
+
break;
|
|
163
|
+
case "yaml":
|
|
164
|
+
default:
|
|
165
|
+
output = yaml.dump(validOpenAPI, { indent: this.config.indent });
|
|
166
|
+
break;
|
|
185
167
|
}
|
|
168
|
+
try {
|
|
169
|
+
fs.writeFileSync(this.config.file, output);
|
|
170
|
+
this.log(
|
|
171
|
+
"OpenAPI v3 Documentation Successfully Written",
|
|
172
|
+
this.logTypes.SUCCESS
|
|
173
|
+
);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
this.log(
|
|
176
|
+
`ERROR: An error was thrown whilst writing the openAPI Documentation`,
|
|
177
|
+
this.logTypes.ERROR
|
|
178
|
+
);
|
|
179
|
+
throw new this.serverless.classes.Error(err);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
186
182
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (err) {
|
|
190
|
-
this.log(`ERROR: An error was thrown when generating the postman collection`, this.logTypes.ERROR)
|
|
191
|
-
throw new this.serverless.classes.Error(err)
|
|
192
|
-
}
|
|
183
|
+
async generationAndValidation() {
|
|
184
|
+
const generator = new DefinitionGenerator(this.serverless);
|
|
193
185
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
186
|
+
this.log(`Generating OpenAPI documentation`, this.logTypes.NOTICE);
|
|
187
|
+
await generator.parse().catch((err) => {
|
|
188
|
+
this.log(
|
|
189
|
+
`ERROR: An error was thrown generating the OpenAPI v3 documentation`,
|
|
190
|
+
this.logTypes.ERROR
|
|
191
|
+
);
|
|
192
|
+
throw new this.serverless.classes.Error(err);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
this.log(
|
|
196
|
+
`Validating generated OpenAPI documentation`,
|
|
197
|
+
this.logTypes.NOTICE
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
await generator.validate().catch((err) => {
|
|
201
|
+
this.log(
|
|
202
|
+
`ERROR: An error was thrown validating the OpenAPI v3 documentation`,
|
|
203
|
+
this.logTypes.ERROR
|
|
204
|
+
);
|
|
205
|
+
this.validationErrorDetails(err);
|
|
206
|
+
if (this.config.validationWarn === false) {
|
|
207
|
+
throw new this.serverless.classes.Error(err);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
this.log(
|
|
212
|
+
"OpenAPI v3 Documentation Successfully Generated",
|
|
213
|
+
this.logTypes.SUCCESS
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
return generator.openAPI;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
createPostman(openAPI) {
|
|
220
|
+
const postmanGeneration = (err, result) => {
|
|
221
|
+
if (err) {
|
|
222
|
+
this.log(
|
|
223
|
+
`ERROR: An error was thrown when generating the postman collection`,
|
|
224
|
+
this.logTypes.ERROR
|
|
225
|
+
);
|
|
226
|
+
throw new this.serverless.classes.Error(err);
|
|
202
227
|
}
|
|
203
228
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
config.postmanCollection = this.serverless.processedInput.options.postmanCollection || null
|
|
224
|
-
|
|
225
|
-
if (['yaml', 'json'].indexOf(config.format.toLowerCase()) < 0) {
|
|
226
|
-
throw new this.serverless.classes.Error('Invalid Output Format Specified - must be one of "yaml" or "json"')
|
|
229
|
+
this.log(
|
|
230
|
+
"postman collection v2 Documentation Successfully Generated",
|
|
231
|
+
this.logTypes.SUCCESS
|
|
232
|
+
);
|
|
233
|
+
try {
|
|
234
|
+
fs.writeFileSync(
|
|
235
|
+
this.config.postmanCollection,
|
|
236
|
+
JSON.stringify(result.output[0].data)
|
|
237
|
+
);
|
|
238
|
+
this.log(
|
|
239
|
+
"postman collection v2 Documentation Successfully Written",
|
|
240
|
+
this.logTypes.SUCCESS
|
|
241
|
+
);
|
|
242
|
+
} catch (err) {
|
|
243
|
+
this.log(
|
|
244
|
+
`ERROR: An error was thrown whilst writing the postman collection`,
|
|
245
|
+
this.logTypes.ERROR
|
|
246
|
+
);
|
|
247
|
+
throw new this.serverless.classes.Error(err);
|
|
227
248
|
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
PostmanGenerator.convert(
|
|
252
|
+
{ type: "json", data: JSON.parse(JSON.stringify(openAPI)) },
|
|
253
|
+
{},
|
|
254
|
+
postmanGeneration
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
processCliInput() {
|
|
259
|
+
const config = {
|
|
260
|
+
format: "json",
|
|
261
|
+
file: "openapi.json",
|
|
262
|
+
indent: 2,
|
|
263
|
+
openApiVersion: "3.0.0",
|
|
264
|
+
postmanCollection: "postman.json",
|
|
265
|
+
validationWarn: false,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
config.indent = this.serverless.processedInput.options.indent || 2;
|
|
269
|
+
config.format = this.serverless.processedInput.options.format || "json";
|
|
270
|
+
config.openApiVersion =
|
|
271
|
+
this.serverless.processedInput.options.openApiVersion || "3.0.0";
|
|
272
|
+
config.postmanCollection =
|
|
273
|
+
this.serverless.processedInput.options.postmanCollection || null;
|
|
274
|
+
config.validationWarn =
|
|
275
|
+
this.serverless.processedInput.options.validationWarn || false;
|
|
276
|
+
|
|
277
|
+
if (["yaml", "json"].indexOf(config.format.toLowerCase()) < 0) {
|
|
278
|
+
throw new this.serverless.classes.Error(
|
|
279
|
+
'Invalid Output Format Specified - must be one of "yaml" or "json"'
|
|
280
|
+
);
|
|
281
|
+
}
|
|
228
282
|
|
|
229
|
-
|
|
230
|
-
|
|
283
|
+
config.file =
|
|
284
|
+
this.serverless.processedInput.options.output ||
|
|
285
|
+
(config.format === "yaml" ? "openapi.yml" : "openapi.json");
|
|
231
286
|
|
|
232
|
-
|
|
233
|
-
|
|
287
|
+
this.log(
|
|
288
|
+
`${chalk.bold.green("[OPTIONS]")}
|
|
234
289
|
openApiVersion: "${chalk.bold.green(String(config.openApiVersion))}"
|
|
235
290
|
format: "${chalk.bold.green(config.format)}"
|
|
236
291
|
output file: "${chalk.bold.green(config.file)}"
|
|
237
292
|
indentation: "${chalk.bold.green(String(config.indent))}"
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
293
|
+
validationWarn: ${chalk.bold.green(String(config.validationWarn))}
|
|
294
|
+
${
|
|
295
|
+
config.postmanCollection
|
|
296
|
+
? `postman collection: ${chalk.bold.green(config.postmanCollection)}`
|
|
297
|
+
: `\n\n`
|
|
298
|
+
}`
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
this.config = config;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
validationErrorDetails(validationError) {
|
|
305
|
+
this.log(
|
|
306
|
+
`${chalk.bold.yellow(
|
|
307
|
+
"[VALIDATION]"
|
|
308
|
+
)} Failed to validate OpenAPI document: \n`,
|
|
309
|
+
this.logTypes.ERROR
|
|
310
|
+
);
|
|
311
|
+
this.log(
|
|
312
|
+
`${chalk.bold.yellow("Context:")} ${JSON.stringify(
|
|
313
|
+
validationError.options.context[
|
|
314
|
+
validationError.options.context.length - 1
|
|
315
|
+
],
|
|
316
|
+
null,
|
|
317
|
+
2
|
|
318
|
+
)}\n`,
|
|
319
|
+
this.logTypes.ERROR
|
|
320
|
+
);
|
|
321
|
+
this.log(
|
|
322
|
+
`${chalk.bold.yellow("Error Message:")} ${JSON.stringify(
|
|
323
|
+
validationError.message,
|
|
324
|
+
null,
|
|
325
|
+
2
|
|
326
|
+
)}\n`,
|
|
327
|
+
this.logTypes.ERROR
|
|
328
|
+
);
|
|
329
|
+
}
|
|
249
330
|
}
|
|
250
331
|
|
|
251
|
-
module.exports = OpenAPIGenerator
|
|
332
|
+
module.exports = OpenAPIGenerator;
|