parser-js icon indicating copy to clipboard operation
parser-js copied to clipboard

Add validation of message examples

Open derberg opened this issue 4 years ago • 15 comments

Reason/Context

Have a mechanism that validates examples of payload. Examples are used as part of rendered docs and by mocking tools and should be 100% accurate.

Description

Ajv doesn't want to be responsible for examples validation, but it could be done with Ajv plugin, all details here. I did not find any available plugin at the moment. Knowing that Ajv is now under development to support the latest JSON Schema, and it affects Ajv architecture as the plan is to rewrite with TypeScript, I would suggest waiting until they are done with it.

derberg avatar Jun 30 '20 11:06 derberg

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

github-actions[bot] avatar Aug 31 '20 00:08 github-actions[bot]

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

github-actions[bot] avatar Oct 30 '20 00:10 github-actions[bot]

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:

github-actions[bot] avatar Dec 30 '20 00:12 github-actions[bot]

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:

github-actions[bot] avatar Mar 06 '21 00:03 github-actions[bot]

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:

github-actions[bot] avatar May 08 '21 00:05 github-actions[bot]

This one is still very much needed. Should not be complicated because it is about comparing data against schema, and ajv is already used in the parser

derberg avatar May 09 '21 09:05 derberg

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:

github-actions[bot] avatar Jul 09 '21 00:07 github-actions[bot]

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:

github-actions[bot] avatar Sep 08 '21 00:09 github-actions[bot]

+1 To validating examples. It would be a nice to have and a quick way to get feedback on the schema and the example(s) for it.

Weffe avatar Sep 28 '21 18:09 Weffe

@Weffe would it be something you could help with contributing, I can guide you

derberg avatar Sep 29 '21 06:09 derberg

We are also interested in a validation.

In the context of writing tests or even in the production code itself it makes sense to validate event payload types.

For our rest api which is documented in OpenApi3 we use this library: https://www.npmjs.com/package/api-schema-builder. It provides an easy to use validation mechanism which we use as part of our test infrastructure.

E.g. the schema which is created by this library could provide a validation() function.

test() {
  // do some things
  // ...
  // validate
  const message = await getMessage()
  schema.validate(channel, 'publish', message.payload)
}

MerzDaniel avatar Jan 03 '22 10:01 MerzDaniel

@MerzDaniel Hello! Thanks for comment!

Please note that this issue is related to the validation of the examples not after the validation of the specification but during the validation, this means that the user passing the specification to the parser should receive errors/information regarding badly formatted examples for message's payload and headers. As far as your idea is concerned I recommend to create separate issue because it concerns two different things :) Sooner or later we will need a similar feature so I would really ask you to create a separate issue, thanks!

magicmatatjahu avatar Jan 03 '22 12:01 magicmatatjahu

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar May 04 '22 00:05 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Sep 08 '22 00:09 github-actions[bot]

Still valid and it will be resolved in the v2 version.

magicmatatjahu avatar Sep 08 '22 06:09 magicmatatjahu

Issue is resolved in v2 ParserJS - now in https://github.com/asyncapi/parser-js/tree/next-major branch

magicmatatjahu avatar Oct 25 '22 08:10 magicmatatjahu