asyncapi / python-paho-template

Python Paho template for the AsyncAPI generator
Apache License 2.0
26 stars 25 forks source link

python-paho-template doesn't work with latest RC of @asyncapi/generator #32

Closed forsberg closed 3 years ago

forsberg commented 4 years ago

Describe the bug

Trying to use python-paho-template with the latest RC (v1.0.0-rc.13) fails with key.startsWith is not a function

How to Reproduce

$ cd test-ag
$ cat package.json
{
  "name": "test-ag",
  "version": "0.0.0",
  "description": "Test Asyncapi generator / Paho MQTT Template",
  "dependencies": {
    "@asyncapi/generator": "v1.0.0-rc.13",
    "npm": "^6.14.8"
  },
  "license": "ISC"
}
$ npm install
$ mkdir out
npx ag --debug https://raw.githubusercontent.com/asyncapi/python-paho-template/0f6d7ccc04139ca24cfbb76152d41f3415f60bf9/samples/temperature.yaml @asyncapi/python-paho-template -o out
Something went wrong:
TypeError: key.startsWith is not a function
    at Channel.extension (/home/forsberg/slask/test-ag/node_modules/@asyncapi/parser/lib/mixins/specification-extensions.js:56:14)
    at Channel.ext (/home/forsberg/slask/test-ag/node_modules/@asyncapi/parser/lib/mixins/specification-extensions.js:75:17)
    at getFunctionNameByChannel (/home/forsberg/slask/test-ag/node_modules/@asyncapi/generator/node_modules/@asyncapi/python-paho-template/filters/all.js:297:30)
    at Context.functionName (/home/forsberg/slask/test-ag/node_modules/@asyncapi/generator/node_modules/@asyncapi/python-paho-template/filters/all.js:19:10)
    at Template.root [as rootRenderFunc] (eval at _compile (/home/forsberg/slask/test-ag/node_modules/nunjucks/src/environment.js:631:18), <anonymous>:179:38)
    at Template.render (/home/forsberg/slask/test-ag/node_modules/nunjucks/src/environment.js:550:10)
    at Environment.renderString (/home/forsberg/slask/test-ag/node_modules/nunjucks/src/environment.js:378:17)
    at /home/forsberg/slask/test-ag/node_modules/@asyncapi/generator/lib/generator.js:639:21
    at new Promise (<anonymous>)
    at Generator.renderString (/home/forsberg/slask/test-ag/node_modules/@asyncapi/generator/lib/generator.js:638:12)

Expected behavior

I guess I'll have to suffer a bit from running the bleeding edge generator (and I will investigate if we actually need this), but the expected behaviour was that.. it would generate python code :-)

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity :sleeping: It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation. Thank you for your contributions :heart:

derberg commented 3 years ago

@forsberg hey, I'm not an expert in this template, but looks like there is no issue either with the generator or template but rather the example.

example has this x-scs-function-name but expects this x-function-name. Try to just fix the extension name in the asyncapi file and see if it works as expected

damaru-inc commented 3 years ago

I was unable to reproduce the error. The sample publishing code that gets generated doesn't provide arguments for the SensorReading constructor, but besides that it works.

derberg commented 3 years ago

not able to reproduce so closing

asyncapi-bot commented 3 years ago

:tada: This issue has been resolved in version 0.2.8 :tada:

The release is available on:

Your semantic-release bot :package::rocket: