asyncapi / nodejs-template

This template generates a server using your AsyncAPI document. It supports multiple different protocols, like Kafka or MQTT. It is designed in the way that generated code is a library and with it's API you can start the server, send messages or register a middleware for listening incoming messages. Runtime message validation included.
40 stars 29 forks source link

fix: log the name of the message if it is absent #304

Closed ibishal closed 3 days ago

ibishal commented 4 months ago

Description Added a param messageRuntimeValidation which will log the messageId's if its missing and if false then it will not warn anything(by default it will be true) Screenshot from 2024-07-02 02-18-41 image

image image

Related issue(s)

197

ibishal commented 4 months ago

I'm only worried for those that do not care about validation, and cannot modify their documents to add identifiers, what in their case. We should probably allow to disable validation?

Hey @derberg i have not added this feature, we need to make changes in asyncapi/generator for it right ?

derberg commented 4 months ago

@ibishal no need to add anything to generator.

You simply need to introduce "parameter" feature. So let's say it is called messageRuntimeValidation that by default is set to true. If set to true, we add in generated code message validation code, and we also console log info that some message identifiers are missing. And we also need to log "that if you are not able to modify your asyncapi document to add missing IDs, then disable runtime validation logic by passing parameter messageRuntimeValidation set to false"

makes sense?

ibishal commented 4 months ago

Done @derberg

ibishal commented 3 months ago

I don't think you tested it manually as just looking at the code I see it errors.

I have done manual testing for it. you can see it in the sc of pr description

messageRuntimeValidation parameter is not added to package.json to generator config

It was added in the parameter of generator config in package.json

no info in readme

will add it

ibishal commented 3 months ago

Do we need integration test here @derberg

derberg commented 3 months ago

I think I mixed the issues scope :(

in general idea was that best DX is that user gets a feedback during generation, and not once the template is generated and code build and running

sorry but instead of parameter I think we need generate:before that will do it -> https://www.asyncapi.com/docs/tools/generator/hooks

wdyt?

ibishal commented 2 months ago

sorry but instead of parameter I think we need generate:before that will do it -> https://www.asyncapi.com/docs/tools/generator/hooks

Looks Good

derberg commented 3 days ago

closing, no further activity from the contributor

ibishal commented 1 day ago

@derberg, sorry from my side

i want to finish it, can we open this?