Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example python generated code has multiple issues #192

Open
plague006 opened this issue Aug 6, 2023 · 2 comments
Open

Example python generated code has multiple issues #192

plague006 opened this issue Aug 6, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@plague006
Copy link

Describe the bug

The python code generated from the generator example (https://www.asyncapi.com/tools/generator) has several issues that prevent the code from running (without debugging):

  1. messaging.py:13 sets defaultHost to 'test.mosquitto.org:{port}'. This is invalid in 3 ways. 1: that's not a functional string template 2: the host should not have the port (port is declared independently on L35) 3: if the string template were functional, we would get an error due to using 'port' before it is declared. - To resolve all of this we change the string to 'test.mosquitto.org'
  2. messaging.py:36 uses port 1833 as the hardcoded fallback. This should be port 1883.
  3. main.py:47 "smartylightingStreetlights10ActionStreetlightIdTurnOnMessenger" is not declared. This should be "smartylightingStreetlights10EventStreetlightIdLightingMeasuredMessenger".

Other remarks:
messaging.py:11 - declaring on_connect as a global is not required as the function is in the same module/file.
messaging.py:20 - I don't think self.client.enable_logger() is doing anything as the script is totally silent when it runs normally.

How to Reproduce

Using Python 3.11 (though the issues would apply to all Python 3 versions equally).
Go to https://www.asyncapi.com/tools/generator and switch generator to Python Paho.
Run code block provided.
For the purposes of brevity I will skip creation and activation of a virtual environment.
Install paho with pip install paho-mqtt.
(Note: I am not considering it a bug that there is no requirements file generated as that may be out of scope.)

On line 42 of main, we are instructed to add arguments. So we will change the line to:
payload = TurnOnOffPayload(TurnOnOffPayload.Command("on"), "1999-12-31T23:59:59.999Z")

This should work, per the instructions. However, we will encounter several issues, detailed in the "Describe the bug" section.

Expected behavior

Setting the required arguments should be the only modifications required to make the example functional.

@plague006 plague006 added the bug Something isn't working label Aug 6, 2023
@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@derberg derberg transferred this issue from asyncapi/generator Aug 7, 2023
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant