@asyncapi/generator 1.17.20 → 1.17.22

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
@@ -82,6 +82,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
82
82
  <tr>
83
83
  <td align="center" valign="top" width="33.33%"><a href="https://github.com/swastiksuvam55"><img src="https://avatars.githubusercontent.com/u/90003260?v=4?s=100" width="100px;" alt="swastik suvam singh"/><br /><sub><b>swastik suvam singh</b></sub></a><br /><a href="https://github.com/asyncapi/generator/commits?author=swastiksuvam55" title="Code">💻</a></td>
84
84
  <td align="center" valign="top" width="33.33%"><a href="https://blog.orzzh.icu/"><img src="https://avatars.githubusercontent.com/u/33168669?v=4?s=100" width="100px;" alt="GavinZhengOI"/><br /><sub><b>GavinZhengOI</b></sub></a><br /><a href="https://github.com/asyncapi/generator/commits?author=GavinZhengOI" title="Documentation">📖</a></td>
85
+ <td align="center" valign="top" width="33.33%"><a href="https://github.com/lmgyuan"><img src="https://avatars.githubusercontent.com/u/16447041?v=4?s=100" width="100px;" alt="lmgyuan"/><br /><sub><b>lmgyuan</b></sub></a><br /><a href="https://github.com/asyncapi/generator/commits?author=lmgyuan" title="Documentation">📖</a></td>
85
86
  </tr>
86
87
  </tbody>
87
88
  </table>
@@ -67,10 +67,22 @@ components:
67
67
 
68
68
  1. Create a new directory for your template named **python-mqtt-client-template**.
69
69
  2. Install the AsyncAPI CLI using the command `npm install -g @asyncapi/cli`.
70
- 3. Create a new folder **test/fixtures** with a file named **asyncapi.yml** in your fixtures directory. This file is used to define the **structure** of your template.
71
- 4. Create a new file named **package.json** in your template directory. This file is used to define the **dependencies** for your template.
72
- 5. Create a new file named **index.js** in your **template** directory. This file is used to define the **logic** for your template.
73
- 6. Create a **test.py** file to validate the logic of your application.
70
+ 3. Create a new folder **test/fixtures** with a file named **asyncapi.yml** in your fixtures directory. This file is used to define the **structure** of your template. You can copy the above example and paste it in your **asyncapi.yml** document.
71
+ 4. Create a new file named **package.json** in your **python-mqtt-client-template** directory. This file is used to define the **dependencies** for your template.
72
+ 5. Create a new folder **python-mqtt-client-template/template**. Create a new file named **index.js** in your **template** directory. This file is used to define the **logic** for your template.
73
+ 6. Create a **test.py** file to validate the logic of your application. Don't worry about this file for now. The tutorial will tell you how to create it later.
74
+
75
+ Now your directory should look like this:
76
+
77
+ ```
78
+ python-mqtt-client-template
79
+ ├── template
80
+ │ └── index.js
81
+ ├── test
82
+ │ └── fixtures
83
+ │ └── asyncapi.yml
84
+ └── package.json
85
+ ```
74
86
 
75
87
  Lets break it down:
76
88
 
@@ -110,7 +122,7 @@ Here's what is contained in the code snippet above:
110
122
  - **supportedProtocols** - A list that specifies which protocols are supported by your template.
111
123
  - **dependencies** - specifies which version of [`@asyncapi/generator-react-sdk`](https://github.com/asyncapi/generator-react-sdk) should be used.
112
124
 
113
- Run the command `npm install` on your terminal to install the dependencies specified in **package.json**.
125
+ Navigate to the ****python-mqtt-client-template** directory. Run the command `npm install` on your terminal to install the dependencies specified in **package.json**.
114
126
 
115
127
  ### index.js file
116
128
 
@@ -143,7 +155,7 @@ The `asyncapi.info().title()` returns `Temperature Service`.
143
155
 
144
156
  ### Test using AsyncAPI CLI
145
157
 
146
- To see this in action, run `asyncapi generate fromTemplate test/fixtures/asyncapi.yml ./ -o test/project` command on your terminal. If successful, you'll see the message below on your terminal:
158
+ To see this in action, navigate to the **python-mqtt-client-template** directory. Then, run `asyncapi generate fromTemplate test/fixtures/asyncapi.yml ./ -o test/project` command on your terminal. If successful, you'll see the message below on your terminal:
147
159
 
148
160
  ``` cmd
149
161
  Generation in progress. Keep calm and wait a bit... done
@@ -173,7 +185,7 @@ In this section, you'll:
173
185
 
174
186
  ### 1. Create the client
175
187
 
176
- The following is the sample code of the Python client you generated [above](#test-using-asyncapi-cli) using the Paho-MQTT library after running the `asyncapi generate fromTemplate test/fixtures/asyncapi.yml ./ -o test/project` command.
188
+ Here is the sample code to be pasted in the client.py you generated above running the `asyncapi generate fromTemplate test/fixtures/asyncapi.yml ./ -o test/project` command. It uses the `paho-mqtt` package.
177
189
 
178
190
  ``` python
179
191
  # 1
@@ -213,6 +225,20 @@ In summary, this code sets up an MQTT client using the Paho-MQTT library. It con
213
225
  You'll interact with the Temperature Service using the client module you created above. You'll create an instance of the client using `client = TemperatureServiceClient()` and then use `client.sendTemperatureChange` function to publish messages that Temperature Service is subscribed to.
214
226
  Create a **test/project/test.py** file in your project and add the code snippet below:
215
227
 
228
+ Now your directory should look like this:
229
+
230
+ ```
231
+ python-mqtt-client-template
232
+ ├── template
233
+ │ └── index.js
234
+ └── test
235
+ ├── fixtures
236
+ │ └── asyncapi.yml
237
+ └── project
238
+ ├── client.py
239
+ └── test.py
240
+ ```
241
+
216
242
  ``` python
217
243
  from client import TemperatureServiceClient
218
244
  from random import randrange
@@ -435,7 +461,7 @@ You'll then need to template to dynamically generate `sendTemperatureDrop` and `
435
461
  </Text>
436
462
  ```
437
463
 
438
- It's recommended to put reusable components outside template directory in a new directory called **components**. You'll create a component that will dynamically generate functions in the output for as many channels as there are in your AsyncAPI document that contain a `publish` operation. Add the following code in **components/TopicFunction.js** file:
464
+ It's recommended to put reusable components outside the template directory in a new directory called components. You'll create a component that will dynamically generate functions in the output for as many channels as there are in your AsyncAPI document that contains a `publish` operation. Add the following code in the **python-mqtt-client-template/components/TopicFunction.js** file, after creating the **python-mqtt-client-template/components/** directory:
439
465
 
440
466
  ```js
441
467
  /*
@@ -512,6 +538,23 @@ export default function ({ asyncapi, params }) {
512
538
 
513
539
  ```
514
540
 
541
+ Now your directory should look like this:
542
+
543
+ ```
544
+ python-mqtt-client-template
545
+ ├── components
546
+ │ └── TopicFunction.js
547
+ ├── template
548
+ │ └── index.js
549
+ └── test
550
+ ├── fixtures
551
+ │ └── asyncapi.yml
552
+ └── project
553
+ ├── client.py
554
+ └── test.py
555
+ ```
556
+
557
+
515
558
  Run `npm test` on your terminal to ensure everything works as expected.
516
559
 
517
560
  In the next section, you'll add another channel to **asyncapi.yml** file called `temperature/dropped` and `temperature/risen` then run the template again to make sure it still works as expected.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asyncapi/generator",
3
- "version": "1.17.20",
3
+ "version": "1.17.22",
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": "^1.0.16",
52
- "@asyncapi/parser": "^3.0.12",
52
+ "@asyncapi/parser": "^3.0.13",
53
53
  "@npmcli/arborist": "5.6.3",
54
54
  "@smoya/multi-parser": "^5.0.0",
55
55
  "ajv": "^8.12.0",