@asyncapi/generator 1.13.0 → 1.13.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 CHANGED
@@ -26,10 +26,10 @@ 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
- * [.originalAsyncAPI](#Generator+originalAsyncAPI) : `String`
30
- * [.generate(asyncapiDocument)](#Generator+generate) ⇒ `Promise`
29
+ * [.generate(asyncapiDocument, [parseOptions])](#Generator+generate) `Promise`
30
+ * [.parseInput()](#Generator+parseInput)
31
31
  * [.configureTemplate()](#Generator+configureTemplate)
32
- * [.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise`
32
+ * ~~[.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise`~~
33
33
  * [.generateFromURL(asyncapiURL)](#Generator+generateFromURL) ⇒ `Promise`
34
34
  * [.generateFromFile(asyncapiFile)](#Generator+generateFromFile) ⇒ `Promise`
35
35
  * [.installTemplate([force])](#Generator+installTemplate)
@@ -163,13 +163,6 @@ The template parameters. The structure for this object is based on each individu
163
163
 
164
164
  **Kind**: instance property of [`Generator`](#Generator)
165
165
 
166
- <a name="Generator+originalAsyncAPI"></a>
167
-
168
- * generator.originalAsyncAPI : `String`** :
169
- AsyncAPI string to use as a source.
170
-
171
- **Kind**: instance property of [`Generator`](#Generator)
172
-
173
166
  <a name="Generator+generate"></a>
174
167
 
175
168
  ### generator.generate
@@ -178,7 +171,8 @@ Generates files from a given template and an AsyncAPIDocument object.
178
171
  **Kind**: instance method of [`Generator`](#Generator)
179
172
  **Params**
180
173
 
181
- - asyncapiDocument `AsyncAPIDocument` - AsyncAPIDocument object to use as source.
174
+ - asyncapiDocument `AsyncAPIDocument` | `string` - AsyncAPIDocument object to use as source.
175
+ - [parseOptions] `Object` ` = {}` - AsyncAPI Parser parse options. Check out [@asyncapi/parser](https://www.github.com/asyncapi/parser-js) for more information. Remember to use the right options to the right parser depending on the template you are using.
182
176
 
183
177
  **Example**
184
178
  ```js
@@ -199,6 +193,13 @@ try {
199
193
  }
200
194
  ```
201
195
 
196
+ <a name="Generator+parseInput"></a>
197
+
198
+ * generator.parseInput()** :
199
+ Parse the generator input based on the template `templateConfig.apiVersion` value.
200
+
201
+ **Kind**: instance method of [`Generator`](#Generator)
202
+
202
203
  <a name="Generator+configureTemplate"></a>
203
204
 
204
205
  * generator.configureTemplate()** :
@@ -208,7 +209,9 @@ Configure the templates based the desired renderer.
208
209
 
209
210
  <a name="Generator+generateFromString"></a>
210
211
 
211
- ### generator.generateFromString
212
+ ### ~~generator.generateFromString~~
213
+ ***Deprecated***
214
+
212
215
  Generates files from a given template and AsyncAPI string.
213
216
 
214
217
  **Kind**: instance method of [`Generator`](#Generator)
package/lib/parser.js CHANGED
@@ -8,17 +8,18 @@ const parser = module.exports;
8
8
  * Convert the template defined value `apiVersion: 'v1'` to only contain the numeric value `1`.
9
9
  */
10
10
  parser.sanitizeTemplateApiVersion = (apiVersion) => {
11
+ if (!apiVersion) return;
11
12
  if (apiVersion && apiVersion.length > 1) {
12
- return apiVersion.substring(1);
13
+ return Number(apiVersion.substring(1));
13
14
  }
14
- return apiVersion;
15
+ return Number(apiVersion);
15
16
  };
16
17
 
17
18
  parser.parse = async (asyncapi, oldOptions, generator) => {
18
19
  let apiVersion = this.sanitizeTemplateApiVersion(generator.templateConfig.apiVersion);
19
20
  // Defaulting to apiVersion v1 to convert it to the Parser-API v1 afterwards.
20
21
  if (!this.usesNewAPI(generator.templateConfig)) {
21
- apiVersion = '1';
22
+ apiVersion = 1;
22
23
  }
23
24
  const options = convertOldOptionsToNew(oldOptions, generator);
24
25
  const parser = NewParser(apiVersion, {parserOptions: options, includeSchemaParsers: true});
@@ -34,7 +35,7 @@ parser.parse = async (asyncapi, oldOptions, generator) => {
34
35
  * If the template expect one of the Parser-API versions, it must be above 0
35
36
  */
36
37
  parser.usesNewAPI = (templateConfig = {}) => {
37
- return Number(this.sanitizeTemplateApiVersion(templateConfig.apiVersion)) > 0;
38
+ return this.sanitizeTemplateApiVersion(templateConfig.apiVersion) > 0;
38
39
  };
39
40
 
40
41
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asyncapi/generator",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "The AsyncAPI generator. It can generate documentation, code, anything!",
5
5
  "main": "./lib/generator.js",
6
6
  "bin": {
@@ -51,7 +51,7 @@
51
51
  "@asyncapi/generator-react-sdk": "^0.2.23",
52
52
  "@asyncapi/parser": "2.1.0",
53
53
  "@npmcli/arborist": "^2.2.4",
54
- "@smoya/multi-parser": "3.0.0",
54
+ "@smoya/multi-parser": "^4.0.0",
55
55
  "ajv": "^8.12.0",
56
56
  "chokidar": "^3.4.0",
57
57
  "commander": "^6.1.0",