@asyncapi/generator 1.14.0 → 1.14.1
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/docs/api.md +130 -2
- package/package.json +2 -2
package/docs/api.md
CHANGED
|
@@ -26,7 +26,15 @@ Reference API documentation for AsyncAPI Generator library.
|
|
|
26
26
|
* [.hooks](#Generator+hooks) : `Object`
|
|
27
27
|
* [.mapBaseUrlToFolder](#Generator+mapBaseUrlToFolder) : `Object`
|
|
28
28
|
* [.templateParams](#Generator+templateParams) : `Object`
|
|
29
|
-
* [.generate(asyncapiDocument, [parseOptions])](#Generator+generate) ⇒ `Promise
|
|
29
|
+
* [.generate(asyncapiDocument, [parseOptions])](#Generator+generate) ⇒ `Promise.<void>`
|
|
30
|
+
* [.validateAsyncAPIDocument(asyncapiDocument)](#Generator+validateAsyncAPIDocument)
|
|
31
|
+
* [.setupOutput()](#Generator+setupOutput)
|
|
32
|
+
* [.setupFSOutput()](#Generator+setupFSOutput) ⇒ `Promise.<void>`
|
|
33
|
+
* [.setLogLevel()](#Generator+setLogLevel) ⇒ `void`
|
|
34
|
+
* [.installAndSetupTemplate()](#Generator+installAndSetupTemplate) ⇒ `Promise.<{templatePkgName: string, templatePkgPath: string}>`
|
|
35
|
+
* [.configureTemplateWorkflow(parseOptions)](#Generator+configureTemplateWorkflow) ⇒ `Promise.<void>`
|
|
36
|
+
* [.handleEntrypoint()](#Generator+handleEntrypoint) ⇒ `Promise.<void>`
|
|
37
|
+
* [.executeAfterHook()](#Generator+executeAfterHook) ⇒ `Promise.<void>`
|
|
30
38
|
* [.parseInput()](#Generator+parseInput)
|
|
31
39
|
* [.configureTemplate()](#Generator+configureTemplate)
|
|
32
40
|
* ~~[.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise`~~
|
|
@@ -169,11 +177,19 @@ The template parameters. The structure for this object is based on each individu
|
|
|
169
177
|
Generates files from a given template and an AsyncAPIDocument object.
|
|
170
178
|
|
|
171
179
|
**Kind**: instance method of [`Generator`](#Generator)
|
|
180
|
+
**Returns**: `Promise.<void>` - A Promise that resolves when the generation is completed.
|
|
172
181
|
**Params**
|
|
173
182
|
|
|
174
183
|
- asyncapiDocument `AsyncAPIDocument` | `string` - AsyncAPIDocument object to use as source.
|
|
175
|
-
- [parseOptions] `Object` ` = {}` - AsyncAPI Parser parse options.
|
|
184
|
+
- [parseOptions] `Object` ` = {}` - AsyncAPI Parser parse options.
|
|
185
|
+
Check out [@asyncapi/parser](https://www.github.com/asyncapi/parser-js) for more information.
|
|
186
|
+
Remember to use the right options for the right parser depending on the template you are using.
|
|
176
187
|
|
|
188
|
+
**Example**
|
|
189
|
+
```js
|
|
190
|
+
await generator.generate(myAsyncAPIdocument);
|
|
191
|
+
console.log('Done!');
|
|
192
|
+
```
|
|
177
193
|
**Example**
|
|
178
194
|
```js
|
|
179
195
|
generator
|
|
@@ -193,6 +209,118 @@ try {
|
|
|
193
209
|
}
|
|
194
210
|
```
|
|
195
211
|
|
|
212
|
+
<a name="Generator+validateAsyncAPIDocument"></a>
|
|
213
|
+
|
|
214
|
+
### generator.validateAsyncAPIDocument
|
|
215
|
+
Validates the provided AsyncAPI document.
|
|
216
|
+
|
|
217
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
218
|
+
**Throws**:
|
|
219
|
+
|
|
220
|
+
- `Error` Throws an error if the document is not valid.
|
|
221
|
+
|
|
222
|
+
**Since**: 10/9/2023 - 4:26:33 PM
|
|
223
|
+
**Params**
|
|
224
|
+
|
|
225
|
+
- asyncapiDocument `*` - The AsyncAPI document to be validated.
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
<a name="Generator+setupOutput"></a>
|
|
229
|
+
|
|
230
|
+
* generator.setupOutput()** :
|
|
231
|
+
Sets up the output configuration based on the specified output type.
|
|
232
|
+
|
|
233
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
234
|
+
**Throws**:
|
|
235
|
+
|
|
236
|
+
- `Error` If 'output' is set to 'string' without providing 'entrypoint'.
|
|
237
|
+
|
|
238
|
+
**Example**
|
|
239
|
+
```js
|
|
240
|
+
const generator = new Generator();
|
|
241
|
+
generator.setupOutput();
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
<a name="Generator+setupFSOutput"></a>
|
|
245
|
+
|
|
246
|
+
* generator.setupFSOutput() ⇒ `Promise.<void>`** :
|
|
247
|
+
Sets up the file system (FS) output configuration.
|
|
248
|
+
|
|
249
|
+
This function creates the target directory if it does not exist and verifies
|
|
250
|
+
the target directory if forceWrite is not enabled.
|
|
251
|
+
|
|
252
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
253
|
+
**Returns**: `Promise.<void>` - A promise that fulfills when the setup is complete.
|
|
254
|
+
**Throws**:
|
|
255
|
+
|
|
256
|
+
- `Error` If verification of the target directory fails and forceWrite is not enabled.
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
<a name="Generator+setLogLevel"></a>
|
|
260
|
+
|
|
261
|
+
* generator.setLogLevel() ⇒ `void`** :
|
|
262
|
+
Sets the log level based on the debug option.
|
|
263
|
+
|
|
264
|
+
If the debug option is enabled, the log level is set to 'debug'.
|
|
265
|
+
|
|
266
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
267
|
+
|
|
268
|
+
<a name="Generator+installAndSetupTemplate"></a>
|
|
269
|
+
|
|
270
|
+
* generator.installAndSetupTemplate() ⇒ `Promise.<{templatePkgName: string, templatePkgPath: string}>`** :
|
|
271
|
+
Installs and sets up the template for code generation.
|
|
272
|
+
|
|
273
|
+
This function installs the specified template using the provided installation option,
|
|
274
|
+
sets up the necessary directory paths, loads the template configuration, and returns
|
|
275
|
+
information about the installed template.
|
|
276
|
+
|
|
277
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
278
|
+
**Returns**: `Promise.<{templatePkgName: string, templatePkgPath: string}>` - A promise that resolves to an object containing the name and path of the installed template.
|
|
279
|
+
|
|
280
|
+
<a name="Generator+configureTemplateWorkflow"></a>
|
|
281
|
+
|
|
282
|
+
### generator.configureTemplateWorkflow
|
|
283
|
+
Configures the template workflow based on provided parsing options.
|
|
284
|
+
|
|
285
|
+
This function performs the following steps:
|
|
286
|
+
1. Parses the input AsyncAPI document using the specified parse options.
|
|
287
|
+
2. Validates the template configuration and parameters.
|
|
288
|
+
3. Configures the template based on the parsed AsyncAPI document.
|
|
289
|
+
4. Registers filters, hooks, and launches the 'generate:before' hook if applicable.
|
|
290
|
+
|
|
291
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
292
|
+
**Returns**: `Promise.<void>` - A promise that resolves when the configuration is completed.
|
|
293
|
+
**Params**
|
|
294
|
+
|
|
295
|
+
- parseOptions `*` - Options for parsing the AsyncAPI document.
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
<a name="Generator+handleEntrypoint"></a>
|
|
299
|
+
|
|
300
|
+
* generator.handleEntrypoint() ⇒ `Promise.<void>`** :
|
|
301
|
+
Handles the logic for the template entrypoint.
|
|
302
|
+
|
|
303
|
+
If an entrypoint is specified:
|
|
304
|
+
- Resolves the absolute path of the entrypoint file.
|
|
305
|
+
- Throws an error if the entrypoint file doesn't exist.
|
|
306
|
+
- Generates a file or renders content based on the output type.
|
|
307
|
+
- Launches the 'generate:after' hook if the output is 'fs'.
|
|
308
|
+
|
|
309
|
+
If no entrypoint is specified, generates the directory structure.
|
|
310
|
+
|
|
311
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
312
|
+
**Returns**: `Promise.<void>` - A promise that resolves when the entrypoint logic is completed.
|
|
313
|
+
|
|
314
|
+
<a name="Generator+executeAfterHook"></a>
|
|
315
|
+
|
|
316
|
+
* generator.executeAfterHook() ⇒ `Promise.<void>`** :
|
|
317
|
+
Executes the 'generate:after' hook.
|
|
318
|
+
|
|
319
|
+
Launches the after-hook to perform additional actions after code generation.
|
|
320
|
+
|
|
321
|
+
**Kind**: instance method of [`Generator`](#Generator)
|
|
322
|
+
**Returns**: `Promise.<void>` - A promise that resolves when the after-hook execution is completed.
|
|
323
|
+
|
|
196
324
|
<a name="Generator+parseInput"></a>
|
|
197
325
|
|
|
198
326
|
* generator.parseInput()** :
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asyncapi/generator",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "The AsyncAPI generator. It can generate documentation, code, anything!",
|
|
5
5
|
"main": "./lib/generator.js",
|
|
6
6
|
"bin": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"homepage": "https://github.com/asyncapi/generator",
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@asyncapi/generator-react-sdk": "^0.2.23",
|
|
52
|
-
"@asyncapi/parser": "2.1.
|
|
52
|
+
"@asyncapi/parser": "^2.1.1",
|
|
53
53
|
"@npmcli/arborist": "^2.2.4",
|
|
54
54
|
"@smoya/multi-parser": "^4.0.0",
|
|
55
55
|
"ajv": "^8.12.0",
|