@asyncapi/generator 2.6.0 → 2.7.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/Dockerfile +7 -8
  3. package/docs/asyncapi-document.md +2 -1
  4. package/docs/configuration-file.md +112 -33
  5. package/docs/generator-template-java.md +560 -0
  6. package/docs/generator-template.md +62 -29
  7. package/docs/hooks.md +3 -3
  8. package/docs/installation-guide.md +5 -51
  9. package/docs/migration-cli.md +5 -5
  10. package/docs/migration-nunjucks-react.md +1 -1
  11. package/docs/nunjucks-render-engine.md +4 -2
  12. package/docs/template.md +2 -2
  13. package/docs/usage.md +14 -32
  14. package/docs/versioning.md +3 -1
  15. package/lib/conditionalGeneration.js +162 -0
  16. package/lib/filtersRegistry.js +1 -1
  17. package/lib/generator.js +93 -40
  18. package/lib/hooksRegistry.js +8 -1
  19. package/lib/logMessages.js +6 -1
  20. package/lib/parser.js +10 -0
  21. package/lib/templateConfigValidator.js +30 -1
  22. package/package.json +4 -5
  23. package/test/generator.test.js +1 -1
  24. package/test/hooksRegistry.test.js +173 -0
  25. package/test/integration.test.js +47 -0
  26. package/test/parser.test.js +100 -2
  27. package/test/templateConfigValidator.test.js +18 -1
  28. package/test/test-project/README.md +5 -1
  29. package/test/test-project/docker-compose.yml +7 -15
  30. package/test/test-project/test-project.test.js +6 -2
  31. package/test/test-project/test-registry.test.js +7 -2
  32. package/test/test-project/test.sh +1 -1
  33. package/test/test-templates/nunjucks-template/package-lock.json +43 -119
  34. package/test/test-templates/nunjucks-template/package.json +1 -1
  35. package/test/test-templates/react-template/.ageneratorrc +33 -0
  36. package/test/test-templates/react-template/package.json +5 -21
  37. package/test/test-templates/react-template/template/conditionalFile.txt +0 -0
  38. package/test/test-templates/react-template/template/conditionalFolder/conditionalFile.txt +0 -0
  39. package/test/test-templates/react-template/template/conditionalFolder2/input.txt +0 -0
  40. package/test/utils.test.js +53 -0
  41. package/test/test-project/test-entrypoint.sh +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,152 @@
1
1
  # @asyncapi/generator
2
2
 
3
+ ## 2.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a51f90e: Release of `generator-react-sdk` as part of the `generator` monorepo.
8
+
9
+ With this release the code from https://github.com/asyncapi/generator-react-sdk is considered to be an archive, and all future development will take place in this repository under `/apps/react-sdk`.
10
+
11
+ - Updated dependencies [a51f90e]
12
+ - @asyncapi/generator-react-sdk@1.1.3
13
+
14
+ ## 2.7.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 802ad41: ### What's New
19
+
20
+ - Introduced a new `conditionalGeneration` configuration for templates.
21
+ - Supports conditional generation of both files and folders.
22
+ - Enables conditions based on values from the AsyncAPI document (`subject`) and custom template `parameters`.
23
+ - The **`parameter`** allows users to pass custom flags or values at generation time (via the CLI or programmatically) to control what parts of the template get rendered.
24
+ - **Addition of new config file `.ageneratorrc`**: Previously, generator configuration had to be defined in the `package.json` file. Now, you can define the configuration in a separate `.ageneratorrc` file. The configuration defined in the `.ageneratorrc` file will override any configuration defined in `package.json`. The generator will first check for the `.ageneratorrc` file in the template's root directory, and if not found, it will look for the generator config in `package.json`.
25
+
26
+ The `.ageneratorrc` file should be in YAML format.
27
+
28
+ Earlier, the `package.json` for the Python WebSocket client looked like this:
29
+
30
+ ```json
31
+ {
32
+ "name": "@asyncapi/template-python-websocket-client",
33
+ "version": "0.0.1",
34
+ "description": "This is a template generating Python websocket client",
35
+ // ...other configuration...
36
+ "generator": {
37
+ "renderer": "react",
38
+ "apiVersion": "v3",
39
+ "generator": ">=1.3.0 <3.0.0",
40
+ "parameters": {
41
+ "server": {
42
+ "description": "The name of the server described in AsyncAPI document",
43
+ "required": true
44
+ },
45
+ "clientFileName": {
46
+ "description": "The name of the generated client file",
47
+ "required": false,
48
+ "default": "client.py"
49
+ },
50
+ "appendClientSuffix": {
51
+ "description": "Add 'Client' suffix at the end of the class name. This option has no effect if 'customClientName' is specified.",
52
+ "required": false,
53
+ "default": false
54
+ },
55
+ "customClientName": {
56
+ "description": "The custom name for the generated client class",
57
+ "required": false
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ Now after the introduction of the `.ageneratorrc` file, the `package.json` can be simplified by removing the generator configuration:
65
+
66
+ ```json
67
+ {
68
+ "name": "@asyncapi/template-python-websocket-client",
69
+ "version": "0.0.1",
70
+ "description": "This is a template generating Python websocket client",
71
+ "scripts": {
72
+ "test": "npm run test:cleanup && jest --coverage",
73
+ "test:update": "npm run test -- -u",
74
+ "test:cleanup": "rimraf \"test/temp\"",
75
+ "lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
76
+ "lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
77
+ },
78
+ "author": "Lukasz Gornicki <lpgornicki@gmail.com>",
79
+ "license": "Apache-2.0",
80
+ "dependencies": {
81
+ "@asyncapi/generator-react-sdk": "^1.1.2",
82
+ "@asyncapi/generator-helpers": "1.0.0"
83
+ },
84
+ "devDependencies": {
85
+ "@asyncapi/parser": "^3.0.14",
86
+ "@babel/cli": "^7.25.9",
87
+ "@babel/core": "^7.26.0",
88
+ "@babel/preset-env": "^7.26.0",
89
+ "@babel/preset-react": "^7.25.9",
90
+ "jest-esm-transformer": "^1.0.0",
91
+ "@asyncapi/generator": "*",
92
+ "eslint": "^6.8.0",
93
+ "eslint-plugin-jest": "^23.8.2",
94
+ "eslint-plugin-react": "^7.34.1",
95
+ "eslint-plugin-sonarjs": "^0.5.0",
96
+ "rimraf": "^3.0.2"
97
+ },
98
+ "jest": {
99
+ "moduleFileExtensions": ["js", "json", "jsx"],
100
+ "transform": {
101
+ "^.+\\.jsx?$": "babel-jest"
102
+ },
103
+ "moduleNameMapper": {
104
+ "^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
105
+ "^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
106
+ }
107
+ },
108
+ "babel": {
109
+ "presets": [
110
+ "@babel/preset-env",
111
+ [
112
+ "@babel/preset-react",
113
+ {
114
+ "runtime": "automatic"
115
+ }
116
+ ]
117
+ ]
118
+ }
119
+ }
120
+ ```
121
+
122
+ And the equivalent `.ageneratorrc` file would be:
123
+
124
+ ```yaml
125
+ renderer: react
126
+ apiVersion: v3
127
+ generator: ">=1.3.0 <3.0.0"
128
+ parameters:
129
+ server:
130
+ description: The name of the server described in AsyncAPI document
131
+ required: true
132
+ clientFileName:
133
+ description: The name of the generated client file
134
+ required: false
135
+ default: client.py
136
+ appendClientSuffix:
137
+ description: Add 'Client' suffix at the end of the class name. This option has no effect if 'customClientName' is specified.
138
+ required: false
139
+ default: false
140
+ customClientName:
141
+ description: The custom name for the generated client class
142
+ required: false
143
+ ```
144
+
145
+ ### Deprecation notice
146
+
147
+ - The existing `conditionalFile` configuration is now deprecated and will be removed in a future release.
148
+ - To migrate, replace `conditionalFile` with `conditionalGeneration` in your template configuration.
149
+
3
150
  ## 2.6.0
4
151
 
5
152
  ### Minor Changes
package/Dockerfile CHANGED
@@ -1,21 +1,20 @@
1
- ARG ASYNCAPI_GENERATOR_VERSION=1.10.9
2
-
3
1
  FROM node:18-alpine
4
2
 
3
+ ARG ASYNCAPI_GENERATOR_VERSION=1.10.9
4
+
5
5
  WORKDIR /app
6
6
 
7
7
  # Since 0.14.0 release of html-template chromium is needed for pdf generation
8
- ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
9
- ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
8
+ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
9
+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
10
10
 
11
11
  # Since 0.30.0 release Git is supported and required as a dependency
12
12
  # Since 0.14.0 release of html-template chromium is needed for pdf generation.
13
13
  # More custom packages for specific template should not be added to this dockerfile. Instead, we should come up with some extensibility solution.
14
+ # Installing latest released npm package
14
15
  RUN apk --update add git chromium && \
15
- rm -rf /var/lib/apt/lists/* && \
16
- rm /var/cache/apk/*
16
+ rm /var/cache/apk/* && \
17
+ npm install --ignore-scripts -g "@asyncapi/generator@${ASYNCAPI_GENERATOR_VERSION}"
17
18
 
18
- # Installing latest released npm package
19
- RUN npm install -g @asyncapi/generator@$ASYNCAPI_GENERATOR_VERSION
20
19
 
21
20
  ENTRYPOINT [ "ag" ]
@@ -68,9 +68,10 @@ function createAsyncapiFile(generator) {
68
68
 
69
69
  const outputFileName = `asyncapi.${extension}`;
70
70
 
71
- const asyncapiOutputLocation = path.resolve('./'', outputFileName);
71
+ const asyncapiOutputLocation = path.resolve('./', outputFileName);
72
72
 
73
73
  fs.writeFileSync(asyncapiOutputLocation, asyncapi);
74
+ }
74
75
  ```
75
76
 
76
77
  ### Method 2: `asyncapi` and template
@@ -3,30 +3,76 @@ title: "Configuration file"
3
3
  weight: 90
4
4
  ---
5
5
 
6
- The `generator` property from `package.json` file must contain a JSON object that may have the following information:
6
+ You can configure your AsyncAPI Generator template using either a dedicated `.ageneratorrc` YAML file or through the `generator` property in your `package.json` file. Previously, generator configuration had to be defined in the `package.json` file. Now, you can define the configuration in a separate `.ageneratorrc` file. The configuration defined in the `.ageneratorrc` file will override any configuration defined in `package.json`. The generator will first check for the `.ageneratorrc` file in the template's root directory, and if not found, it will look for the generator config in `package.json`.
7
7
 
8
- |Name|Type|Description|
9
- |---|---|---|
10
- |`renderer`| String | Its value can be either `react` or `nunjucks` (default).
11
- |`apiVersion`| String | Determines which **major** version of the [Parser-API](https://github.com/asyncapi/parser-api) the template uses. For example, `v2` for `v2.x.x`. If not specified, the Generator assumes the template is not compatible with the Parser-API so it will use the [Parser-JS v1 API](https://github.com/asyncapi/parser-js/tree/v1.18.1#api-documentation). For templates that need to support AsyncAPI specification v3 make sure to use `v3` [Parser-API](https://github.com/asyncapi/parser-api). If the template uses a version of the Parser-API that is not supported by the Generator, the Generator will throw an error.
12
- |`supportedProtocols`| [String] | A list with all the protocols this template supports.
13
- |`parameters`| Object[String, Object] | An object with all the parameters that can be passed when generating the template. When using the command line, it's done by indicating `--param name=value` or `-p name=value`.
14
- |`parameters[param].description`| String | A user-friendly description about the parameter.
15
- |`parameters[param].default`| Any | Default value of the parameter if not specified. Shouldn't be used for mandatory `required=true` parameters.
16
- |`parameters[param].required`| Boolean | Whether the parameter is required or not.
17
- |`conditionalFiles`| Object[String, Object] | An object containing all the file paths that should be conditionally rendered. Each key represents a file path and each value must be an object with the keys `subject` and `validation`. The file path should be relative to the `template` directory inside the template.
18
- |`conditionalFiles[filePath].subject`| String | The `subject` is a [JMESPath](http://jmespath.org/) query to grab the value you want to apply the condition to. It queries an object with the whole AsyncAPI document and, when specified, the given server. The object looks like this: `{ asyncapi: { ... }, server: { ... } }`. If the template supports `server` parameter, you can access server details like for example protocol this way: `server.protocol`. During validation with `conditionalFiles` only the server that template user selected is available in the specification file. For more information about `server` parameter [read about special parameters](#special-parameters).
19
- |`conditionalFiles[filePath].validation`| Object | The `validation` is a JSON Schema Draft 07 object. This JSON Schema definition will be applied to the JSON value resulting from the `subject` query. If validation doesn't have errors, the condition is met, and therefore the given file will be rendered. Otherwise, the file is ignored. Check [JSON Schema Validation](https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6) document for a list of all possible validation keywords.
20
- |`nonRenderableFiles`| [String] | A list of file paths or [globs](https://en.wikipedia.org/wiki/Glob_(programming)) that must be copied "as-is" to the target directory, i.e., without performing any rendering process. This is useful when you want to copy binary files.
21
- |`generator`| [String] | A string representing the generator version-range the template is compatible with. This value must follow the [semver](https://nodejs.dev/learn/semantic-versioning-using-npm) syntax. E.g., `>=1.0.0`, `>=1.0.0 <=2.0.0`, `~1.0.0`, `^1.0.0`, `1.0.0`, etc. [Read more about semver](https://docs.npmjs.com/about-semantic-versioning).
22
- |`filters`| [String] | A list of modules containing functions that can be used as Nunjucks filters. In case of external modules, remember they need to be added as a dependency in `package.json` of your template.
23
- |`hooks`| Object[String, String] or Object[String, Array[String]] | A list of modules containing hooks, except for the ones you keep locally in your template in the default location. For each module you must specify the exact name of the hook that should be used in the template. For a single hook, you can specify it as a string; for more hooks, you must pass an array of strings. In the case of external modules, remember they need to be added as a dependency in `package.json` of your template. There is also [an official hooks library](hooks#official-library) always included in the generator. As this is a library of multiple hooks, you still need to explicitly specify in the configuration which one you want to use. Use `@asyncapi/generator-hooks` as the library name.
24
8
 
25
- ### Example
9
+ ## Configuration Methods
10
+
11
+ ### Option 1: Using `.ageneratorrc` file (Recommended)
12
+
13
+ Create a `.ageneratorrc` file in the root of your template with YAML syntax. This approach keeps your template configuration separate from package metadata:
14
+
15
+ ```yaml
16
+ renderer: react
17
+ apiVersion: v3
18
+ supportedProtocols:
19
+ - amqp
20
+ - mqtt
21
+
22
+ parameters:
23
+ server:
24
+ description: The server you want to use in the code.
25
+ required: true
26
+ dummyParameter:
27
+ description: Example of parameter with default value.
28
+ default: just a string
29
+ required: false
30
+
31
+ conditionalFiles:
32
+ path/to/file/that/is/relative/to/template/dir/test-amqp.js:
33
+ subject: server.protocol
34
+ validation:
35
+ const: amqp
36
+ path/to/file/that/is/relative/to/template/dir/support.html:
37
+ subject: info.contact
38
+ validation:
39
+ required:
40
+ - url
41
+
42
+ conditionalGeneration:
43
+ conditionalOnFile.js:
44
+ parameter: singleFile
45
+ validation:
46
+ not:
47
+ const: true
48
+ conditionOnFolderInfo:
49
+ subject: info.contact.name
50
+ validation:
51
+ const: API Support
52
+
53
+ nonRenderableFiles:
54
+ - src/api/middlewares/*.*
55
+ - lib/lib/config.js
56
+
57
+ generator: "<2.0.0"
58
+
59
+ filters:
60
+ - my-package-with-filters
61
+
62
+ hooks:
63
+ '@asyncapi/generator-hooks': hookFunctionName
64
+ my-custom-hooks-package:
65
+ - myHook
66
+ - andAnotherOne
67
+
68
+ ```
69
+
70
+ ### Option 2: Using `package.json`
71
+
72
+ Alternatively, you can include your configuration in the `generator` property of your `package.json` file:
26
73
 
27
74
  ```json
28
- "generator":
29
- {
75
+ "generator": {
30
76
  "renderer": "react",
31
77
  "apiVersion": "v3",
32
78
  "supportedProtocols": ["amqp", "mqtt"],
@@ -41,26 +87,32 @@ The `generator` property from `package.json` file must contain a JSON object tha
41
87
  "required": false
42
88
  }
43
89
  },
44
- "conditionalFiles": {
45
- "path/to/file/that/is/relative/to/template/dir/test-amqp.js": {
46
- "subject": "server.protocol",
47
- "validation": {
48
- "const": "amqp"
90
+ "conditionalGeneration": {
91
+ "conditionalOnFile.js": {
92
+ "parameter": "singleFile",
93
+ "validation": {
94
+ "not": { "const": "true" }
95
+ }
96
+ },
97
+ "conditionOnFolder": {
98
+ "parameter": "singleFolder",
99
+ "validation": {
100
+ "not": { "const": "true" }
49
101
  }
50
102
  },
51
- "path/to/file/that/is/relative/to/template/dir/support.html": {
52
- "subject": "info.contact",
53
- "validation": {
54
- "required": ["url"]
103
+ "conditionOnFolderInfo": {
104
+ "subject": "info.contact.name",
105
+ "validation": {
106
+ "const": "API Support"
55
107
  }
56
- }
108
+ },
57
109
  },
58
110
  "nonRenderableFiles": [
59
111
  "src/api/middlewares/*.*",
60
112
  "lib/lib/config.js"
61
113
  ],
62
114
  "generator": "<2.0.0",
63
- "filters":[
115
+ "filters": [
64
116
  "my-package-with-filters"
65
117
  ],
66
118
  "hooks": {
@@ -70,12 +122,39 @@ The `generator` property from `package.json` file must contain a JSON object tha
70
122
  }
71
123
  ```
72
124
 
125
+ > **Note:** If both `.ageneratorrc` file and the `generator` property in `package.json` exist, the configuration from `.ageneratorrc` will override the `package.json` configuration.
126
+
127
+ The `generator` property from `package.json` file and must contain a JSON object and the `ageneratorrc` file must contain a YAML object that may have the following information:
128
+
129
+
130
+ |Name|Type|Description|
131
+ |---|---|---|
132
+ |`renderer`| String | Its value can be either `react` or `nunjucks` (default).
133
+ |`apiVersion`| String | Determines which **major** version of the [Parser-API](https://github.com/asyncapi/parser-api) the template uses. For example, `v2` for `v2.x.x`. If not specified, the Generator assumes the template is not compatible with the Parser-API so it will use the [Parser-JS v1 API](https://github.com/asyncapi/parser-js/tree/v1.18.1#api-documentation). For templates that need to support AsyncAPI specification v3 make sure to use `v3` [Parser-API](https://github.com/asyncapi/parser-api). If the template uses a version of the Parser-API that is not supported by the Generator, the Generator will throw an error.
134
+ |`supportedProtocols`| [String] | A list with all the protocols this template supports.
135
+ |`parameters`| Object[String, Object] | An object with all the parameters that can be passed when generating the template. When using the command line, it's done by indicating `--param name=value` or `-p name=value`.
136
+ |`parameters[param].description`| String | A user-friendly description about the parameter.
137
+ |`parameters[param].default`| Any | Default value of the parameter if not specified. Shouldn't be used for mandatory `required=true` parameters.
138
+ |`parameters[param].required`| Boolean | Whether the parameter is required or not.
139
+ | `conditionalFiles` | Object[String, Object] | An object containing all the file paths that should be conditionally rendered. Each key represents a file path and each value must be an object with the keys `subject` and `validation`. The file path should be relative to the `template` directory inside the template. **Note: It is deprecated and will be removed with future releases. Use `conditionalGeneration` instead.** |
140
+ | `conditionalFiles[filePath].subject` | String | The `subject` is a [JMESPath](http://jmespath.org/) query to grab the value you want to apply the condition to. It queries an object with the whole AsyncAPI document and, when specified, the given server. The object looks like this: `{ asyncapi: { ... }, server: { ... } }`. If the template supports the `server` parameter, you can access server details, for example, `server.protocol`. During validation with `conditionalFiles`, only the server that the template user selected is available in the specification file. For more information about `server` parameter [read about special parameters](#special-parameters). **Note: It is deprecated and will be removed with future releases. Use `conditionalGeneration` instead.** |
141
+ | `conditionalFiles[filePath].validation` | Object | The `validation` is a JSON Schema Draft 07 object. This JSON Schema definition will be applied to the JSON value resulting from the `subject` query. If validation doesn't have errors, the condition is met, and therefore the given file will be rendered. Otherwise, the file is ignored. Check [JSON Schema Validation](https://json-schema.org/draft-07/json-schema-validation.html#rfc.section.6) for a list of all possible validation keywords. **Note: It is deprecated and will be removed with future releases. Use `conditionalGeneration` instead.** |
142
+ |`conditionalGeneration` | Object[String, `{ subject?: String, parameter?: String, validation: Object }`] | An object containing all the file paths or directory names that should be conditionally rendered. Each key represents a file path or directory name and each value must be an object with the keys `subject`, `parameter` and `validation`. You can use either subject or parameter according to the use case. The path should be relative to the `template` directory inside the template. **Note: conditionalGeneration and conditionalFile are mutually exclusive, which means both cannot be configured at the same time in the template**. |
143
+ |`conditionalGeneration[filePath/directoryName].subject`| String | The `subject` is a [JMESPath](http://jmespath.org/) query to grab the value you want to apply the condition to. It queries an object with the whole AsyncAPI document and, when specified, the given server. The object looks like this: `{ asyncapi: { ... }, server: { ... } }`. If the template supports the `server` parameter, you can access server details like, for example, protocol this way: `server.protocol`. During validation with `conditionalGeneration`, only the server that the template user selected is available in the specification file. For more information about the `server` parameter [read about special parameters](#special-parameters). |
144
+ |`conditionalGeneration[filePath/directoryName].parameter`| String | The `parameter` is the name of a custom template parameter passed through `templateParams` that controls whether a specific file or folder should be included in the generated output. You must define a `validation` rule using a JSON Schema fragment to apply the condition. For example, if you define `"parameter": "includeDocs"` with `"validation": { "const": true }`, the corresponding folder (e.g., `docs/`) will only be generated when the user passes `{ includeDocs: true }`. If `includeDocs` is `false`, it will be skipped. |
145
+ |`conditionalGeneration[filePath/directoryName].validation`| Object (JSON Schema fragment) | The validation defines the condition under which the file or directory will be generated. It must be a valid JSON Schema fragment that validates the value of the parameter. For example, if you want to include a folder only when includeDocs is true, use "validation": `{ "const": true }`. You can also use more complex validation logic, like "enum": ["yes", "true"] or "type": "string" with a "pattern" constraint. If the parameter fails validation, the file or folder will not be included in the generated output. This allows for powerful and flexible control over template generation based on user input. |
146
+ |`nonRenderableFiles`| [String] | A list of file paths or [globs](https://en.wikipedia.org/wiki/Glob_(programming)) that must be copied "as-is" to the target directory, i.e., without performing any rendering process. This is useful when you want to copy binary files.
147
+ |`generator`| [String] | A string representing the generator version-range the template is compatible with. This value must follow the [semver](https://nodejs.dev/learn/semantic-versioning-using-npm) syntax. E.g., `>=1.0.0`, `>=1.0.0 <=2.0.0`, `~1.0.0`, `^1.0.0`, `1.0.0`, etc. [Read more about semver](https://docs.npmjs.com/about-semantic-versioning).
148
+ |`filters`| [String] | A list of modules containing functions that can be used as Nunjucks filters. In case of external modules, remember they need to be added as a dependency in `package.json` of your template.
149
+ |`hooks`| Object[String, String] or Object[String, Array[String]] | A list of modules containing hooks, except for the ones you keep locally in your template in the default location. For each module you must specify the exact name of the hook that should be used in the template. For a single hook, you can specify it as a string; for more hooks, you must pass an array of strings. In the case of external modules, remember they need to be added as a dependency in `package.json` of your template. There is also [an official hooks library](hooks#official-library) always included in the generator. As this is a library of multiple hooks, you still need to explicitly specify in the configuration which one you want to use. Use `@asyncapi/generator-hooks` as the library name.
150
+
151
+ ---
152
+
73
153
  ## Special parameters
74
154
 
75
155
  There are some template parameters that have a special meaning:
76
156
 
77
157
  |Name|Description|
78
158
  |---|---|
79
- |`server`| It is used to let the template know which server from the AsyncAPI specification file you want to use. In some cases, this may be required. For instance, when generating code that connects to a specific server. Use this parameter in case your template relies on users' information about what server from the specification file they want to use during generation. You also need this parameter if you want to use `server.protocol` notation within `conditionalFiles` configuration option. Once you decide to specify this parameter for your template, it is recommended you make it a mandatory parameter otherwise a feature like `conditionalFiles` is not going to work if your users do not use this parameter obligatory.
80
-
159
+ |`server`| It is used to let the template know which server from the AsyncAPI specification file you want to use. In some cases, this may be required. For instance, when generating code that connects to a specific server. Use this parameter in case your template relies on users' information about what server from the specification file they want to use during generation. You also need this parameter if you want to use `server.protocol` notation within `conditionalGeneration` configuration option. Once you decide to specify this parameter for your template, it is recommended you make it a mandatory parameter otherwise a feature like `conditionalGeneration` is not going to work if your users do not use this parameter obligatory.
81
160