jonaslagoni / asyncapi-quicktype-template

Template for generating typed models from AsyncAPI message payloads.
6 stars 3 forks source link

Something went wrong: undefined #4

Closed gardner closed 3 years ago

gardner commented 3 years ago

Hello, Thanks for publishing this code! ๐Ÿ™Œ

I just tried to use it with the ruby quicktype and noticed that it is throwing this error. I am not sure where to dig in to find where it is happening but I thought you may want to know about it:

$ ag --version
1.0.0-rc.13

$ ag https://raw.githubusercontent.com/asyncapi/generator/master/test/docs/dummy.yml \
    @lagoni/asyncapi-quicktype-template \
    -o output \
    --param "quicktypeLanguage=ruby"

Something went wrong:
undefined

$ find .
.
./output

Please note: I tried the --debug flag but no extra output was observed.

gardner commented 3 years ago

I found the place in the generator where this error message is being produced. https://github.com/asyncapi/generator/blob/7a38817990a444f72ab235b17abe72547e3daaab/cli.js#L38

I added an extra line in that package:

  console.error(red(JSON.stringify(err)));

and then ran npm link from within the generator directory. I can see the contents of the err variable:

[{"name":"template","error":{"errno":-2,"code":"ENOENT","syscall":"lstat","path":"/Volumes/src/async/generator/node_modules/@lagoni/asyncapi-quicktype-template/template"}}]
Something went wrong:
undefined

When inspecting that directory:

$ls -la "/Volumes/src/async/generator/node_modules/@lagoni/asyncapi-quicktype-template"
total 32
drwxr-xr-x  8 gardner  staff   256 30 Oct 12:12 .
drwxr-xr-x  4 gardner  staff   128 30 Oct 12:12 ..
-rw-r--r--  1 gardner  staff    12 26 Oct  1985 .eslintignore
-rw-r--r--  1 gardner  staff  2170 26 Oct  1985 .eslintrc
drwxr-xr-x  3 gardner  staff    96 30 Oct 12:12 .github
-rw-r--r--  1 gardner  staff  2568 26 Oct  1985 README.md
drwxr-xr-x  3 gardner  staff    96 30 Oct 12:12 hooks
-rw-r--r--  1 gardner  staff  3312 30 Oct 12:12 package.json

It appears the async generator is looking for a file called template that does not exist. Perhaps I don't understand how the library is intended to be used.

jonaslagoni commented 3 years ago

@gardner Ahh, sorry about that, give me a sec!

jonaslagoni commented 3 years ago

@gardner so the issue you are having atm has been fixed. However I can see that recursive JSON Schemas are not working at all, so I will have to take a look at that more in-depth how to make a fix for that. Do you need this feature ASAP or?

Here is the AsyncAPI document without the recursive properties if that is any use.

AsyncAPI example without circular properties

```yml asyncapi: '2.0.0' externalDocs: description: Find more info here url: https://www.asyncapi.com info: title: Dummy example with all spec features included version: '0.0.1' description: | This is an example of AsyncAPI specification file that is suppose to include all possible features of the AsyncAPI specification. Do not use it on production. It's goal is to support development of documentation and code generation with the [AsyncAPI Generator](https://github.com/asyncapi/generator/) and [Template projects](https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate) license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0 contact: name: API Support url: http://www.asyncapi.com/support email: info@asyncapi.io x-twitter: '@AsyncAPISpec' tags: - name: root-tag1 externalDocs: description: External docs description 1 url: https://www.asyncapi.com/ - name: root-tag2 description: Description 2 externalDocs: url: "https://www.asyncapi.com/" - name: root-tag3 - name: root-tag4 description: Description 4 - name: root-tag5 externalDocs: url: "https://www.asyncapi.com/" servers: dummy-mqtt: url: mqtt://localhost protocol: mqtt description: dummy MQTT broker bindings: mqtt: clientId: guest cleanSession: true dummy-amqp: url: amqp://localhost:{port} protocol: amqp description: dummy AMQP broker protocolVersion: "0.9.1" variables: port: enum: - '15672' - '5672' security: - user-password: [] dommy-kafka: url: http://localhost:{port} protocol: kafka description: dummy Kafka broker variables: port: default: '9092' defaultContentType: application/json channels: dummy/channel/with/{dummy}/parameter/create: description: Dummy channel description. parameters: dummy: $ref: '#/components/parameters/dummy' publish: summary: Inform whenever something dummy is created. description: | Longer description. Still dummy though. operationId: receiveNewDummyInfo tags: - name: oparation-tag1 externalDocs: description: External docs description 1 url: https://www.asyncapi.com/ - name: oparation-tag2 description: Description 2 externalDocs: url: "https://www.asyncapi.com/" - name: oparation-tag3 - name: oparation-tag4 description: Description 4 - name: oparation-tag5 externalDocs: url: "https://www.asyncapi.com/" traits: - $ref: '#/components/operationTraits/kafka' message: $ref: '#/components/messages/dummyCreated' dummy/channel/without/parameter: bindings: amqp: is: routingKey subscribe: operationId: receiveSystemInfo message: $ref: '#/components/messages/dummyInfo' components: messages: dummyCreated: name: dummyCreated title: Dummy created message summary: This is just a dummy create message correlationId: description: This is a dummy correlation ID. location: $message.header#/correlationId tags: - name: message-tag1 externalDocs: description: External docs description 1 url: https://www.asyncapi.com/ - name: message-tag2 description: Description 2 externalDocs: url: "https://www.asyncapi.com/" - name: message-tag3 - name: message-tag4 description: Description 4 - name: message-tag5 externalDocs: url: "https://www.asyncapi.com/" headers: type: object properties: my-custom-app-header: type: string correlationId: type: string payload: $ref: "#/components/schemas/dummyCreated" dummyInfo: name: dummyInfo title: Dummy system info summary: This is just a dummy info message correlationId: location: $message.header#/correlationId description: | More description for a dummy message. It is a dummy system info message. traits: - $ref: '#/components/messageTraits/commonHeaders' payload: $ref: "#/components/schemas/dummyInfo" examples: - headers: my-app-header: 12 payload: prop1: option1 sentAt: 2020-01-31T13:24:53Z - headers: my-app-header: 13 - payload: prop1: option2 sentAt: 2020-01-31T13:24:53Z schemas: dummyCreated: type: object required: - prop2 properties: prop1: type: integer minimum: 0 description: Dummy prop1 prop2: type: string description: Dummy prop2 sentAt: $ref: "#/components/schemas/sentAt" dummyArray: $ref: "#/components/schemas/dummyArray" dummyObject: $ref: "#/components/schemas/dummyObject" dummyInfo: type: object required: - prop1 properties: prop1: type: string enum: - option1 - option2 description: Dummy prop1 sentAt: $ref: "#/components/schemas/sentAt" dummyArray: type: array items: $ref: "#/components/schemas/dummyInfo" dummyObject: type: object properties: dummyObjectProp1: $ref: "#/components/schemas/sentAt" sentAt: type: string format: date-time description: Date and time when the message was sent. securitySchemes: user-password: type: userPassword apiKey: type: apiKey in: user description: Provide your API key as the user and leave the password empty. supportedOauthFlows: type: oauth2 description: Flows to support OAuth 2.0 flows: implicit: authorizationUrl: 'https://authserver.example/auth' scopes: 'dummy:created': Ability to create dummy message 'dymmy:read': Ability to read dummy info password: tokenUrl: 'https://authserver.example/token' scopes: 'dummy:created': Ability to create dummy message 'dymmy:read': Ability to read dummy info clientCredentials: tokenUrl: 'https://authserver.example/token' scopes: 'dummy:created': Ability to create dummy message 'dymmy:read': Ability to read dummy info authorizationCode: authorizationUrl: 'https://authserver.example/auth' tokenUrl: 'https://authserver.example/token' refreshUrl: 'https://authserver.example/refresh' scopes: 'dummy:created': Ability to create dummy message 'dymmy:read': Ability to read dummy info openIdConnectWellKnown: type: openIdConnect openIdConnectUrl: 'https://authserver.example/.well-known' parameters: dummy: description: The ID of the new dummy message. schema: type: string description: Description that not be rendered, as parameter has explicit description. messageTraits: commonHeaders: headers: type: object properties: my-app-header: type: integer minimum: 0 maximum: 100 correlationId: type: string operationTraits: kafka: bindings: kafka: clientId: my-app-id ```

gardner commented 3 years ago

Hello, weโ€™re looking at adopting asyncapi at the company I work with and weโ€™re just doing a survey of the tooling now. So, I donโ€™t need this urgently. I just noticed an issue and thought Iโ€™d report it.

Thanks for asking. ๐Ÿ˜Š

jonaslagoni commented 3 years ago

Ah perfect, and thank you ๐Ÿ‘ You can always tag me in the AsyncAPI Slack channel if you have any questions or need help with anything ๐Ÿ˜„