Skip to content

Commit

Permalink
fix: proper usage of parser on extensions and sample readme (#47)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
Co-authored-by: sebastien andreo <sebastien.andreo@siemens.com>
  • Loading branch information
3 people committed Feb 10, 2021
1 parent ac69378 commit c73c6da
Show file tree
Hide file tree
Showing 4 changed files with 883 additions and 3 deletions.
2 changes: 1 addition & 1 deletion filters/all.js
Expand Up @@ -293,7 +293,7 @@ const getMethods = (obj) => {
function getFunctionNameByChannel(channelName, channel) {
let ret = _.camelCase(channelName);
//console.log('functionName channel: ' + JSON.stringify(channelJson));
let functionName = channel.ext(['x-function-name']);
let functionName = channel.ext('x-function-name');
//console.log('function name for channel ' + channelName + ': ' + functionName);
if (functionName) {
ret = functionName;
Expand Down
43 changes: 43 additions & 0 deletions samples/README.md
@@ -0,0 +1,43 @@
# How to run the sample

## Prerequisites

- Python 3 with `pip` and `paho-mqtt` preinstalled
- Docker

## Run the example

1. Generate the code
```
ag https://raw.githubusercontent.com/asyncapi/python-paho-template/master/samples/temperature.yaml @asyncapi/python-paho-template -o ./generated_code
```
2. Patch main.py to send some data
An example of code:

```
# Example of how to publish a message. You will have to add arguments to the constructor on the next line:
payload = SensorReading("SensorId3",12,SensorReading.BaseUnit.CELSIUS)
```
3. Create Mosquitto broker configuration

Get the example configuration from [here](https://github.com/asyncapi/python-paho-template/blob/master/samples/mosquitto.conf)

> In `mosquitto.conf` we enabled anonymous logging. This **SHOULD NOT** be the case in production.
4. Install and run mosquitto MQTT broker
```
docker run -it -p 0.0.0.0:1883:1883 -p 0.0.0.0:9001:9001 -v $PWD/../samples/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
```
5. Configure .ini file
Rename `config-template.inì` into `config.ini` and paste:
```
[DEFAULT]
host=127.0.0.1
password=
port=1883
username=
```
6. Run your code
```
python main.py
```

0 comments on commit c73c6da

Please sign in to comment.