asyncapi / cli

CLI to work with your AsyncAPI files. You can validate them and in the future use a generator and even bootstrap a new file. Contributions are welcomed!
https://www.asyncapi.com/tools/cli
Apache License 2.0
187 stars 160 forks source link

[BUG] Doesn't work for Hello world example from AsyncAPI #1488

Open slavaGanzin opened 3 months ago

slavaGanzin commented 3 months ago

Describe the bug.

Hello, there awesome work on asyncapi spec!

So I copy and paste this example: https://www.asyncapi.com/docs/tutorials/getting-started/hello-world

asyncapi: 3.0.0
info:
  title: Hello world application
  version: '0.1.0'
channels:
  hello:
    address: 'hello'
    messages:
      sayHelloMessage:
        payload:
          type: string
          pattern: '^hello .+$'
operations:
  receiveHello:
    action: 'receive'
    channel:
      $ref: '#/channels/hello'

And run:

$ asyncapi  generate models python asyncapi.yaml -o python

(node:29818) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
│
 ›   Warning: Python generator, cannot generate this type of model, AnonymousSchema1
◇  Successfully generated the following models: 

So it seems, like Modelina couldn't parse this file, and it could read names (thus, generating AnonymousSchema1)

Expected behavior

Well, generate the code

Screenshots

.

How to Reproduce

.

🥦 Browser

None

👀 Have you checked for similar open issues?

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

github-actions[bot] commented 3 months ago

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.

slavaGanzin commented 3 months ago

Strangely you need to pass title to payload:

asyncapi: 3.0.0
info:
  title: Hello world application
  version: '0.1.0'
channels:
  hello:
    address: 'hello'
    messages:
      sayHelloMessage:  # it doesn't read message name from here
        payload:
          title: SayHelloMessage # so you need to put it here
          type: string
          pattern: '^hello .+$'
operations:
  receiveHello:
    action: 'receive'
    channel:
      $ref: '#/channels/hello'

But now I get:

Could not dereference $ref in input, is all the references correct? 1 error occurred while reading
Amzani commented 3 months ago

Hi @slavaGanzin

The generate model is now part of modelina cc @jonaslagoni could you transfer this issue? Thanks

jonaslagoni commented 3 months ago

I cant transfer it as I am not maintainer of Cli 🙂

jonaslagoni commented 3 months ago

in short @slavaGanzin, it's because Modelina only generate payload representations, not messages. I.e. it is not generating anything for python, unless string can be rendered someway.

    messages:
      sayHelloMessage:  # it doesn't read message name from here
        payload:
          title: SayHelloMessage # so you need to put it here
          type: string
          pattern: '^hello .+$'
slavaGanzin commented 3 months ago

@Amzani @jonaslagoni I know that it is a Modellina responsibility. But I shouldn't - I was advertised that the generator would generate a model, but it didn't. And the problem is actually that the AsyncAPI generator does not deliver what is promised on the AsyncAPI website.

Wck-iipi commented 2 months ago

I would like to work on this issue. However, since this is modelina issue, should I create a new issue and then work on it or do something else?