Specfile with invalid examples considered valid
A specfile with invalid examples is considered a valid specfile when validated with asyncapi validate.
This issue can be reproduced with following example. This file contains an invalid example (missing required field):
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
userSignedUp:
address: user/signedup
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
operations:
onUserSignUp:
action: receive
channel:
$ref: '#/channels/userSignedUp'
messages:
- $ref: '#/channels/userSignedUp/messages/UserSignedUp'
components:
messages:
UserSignedUp:
examples:
- name: Invalid Example
summary: Example is missing required field email
payload:
displayName: My Name
payload:
type: object
required: [displayName, email]
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user
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.
I think it would be interesting to have a flag in the CLI. Something like asyncapi validate --skip-examples.
What version of the parser are you using?
I believed the following Spectral rule takes care of such a validation https://github.com/asyncapi/parser-js/blob/master/src/ruleset/v2/ruleset.ts#L119 🤔
I'm afk, so I can't check this atm.
I'm trying with the latest git version of cli and studio. According to npm, they are using this version:
@asyncapi/[email protected]
@lovebug356 - Can you please check the YML provided, on validating its giving an error at line #18 18:9 error asyncapi3-operation-messages-from-referred-channel Operation message does not belong to the specified channel. operations.user/signedup.subscribe.messages[0]
✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints)
If I try to uncomment the refrence to "UserSignedUp" it errors at a later line: 21:18 error asyncapi-document-resolved "messages" property type must be array components.messages.UserSignedUp
✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints)
@PradeepJoshiFreelancer : Updated the example (adapted file generated by asyncapi new file).
What version of the parser are you using?
I believed the following Spectral rule takes care of such a validation https://github.com/asyncapi/parser-js/blob/master/src/ruleset/v2/ruleset.ts#L119 🤔
I'm afk, so I can't check this atm.
I see you point to a spectral rule in v2 ruleset. I don't see something similar in v3 ruleset. Could it be that it is only supported for v2 at the moment?
I think that's right: it worked in v2 but the tools currently aren't validating examples in v3.
@lovebug356 @PeteAudinate That's right, this example is correctly validated for v2, but not for v3.
@smoya Tested with:
@asyncapi/cli: v1.7.0@asyncapi/parser: v3.0.9
Studio is not throwing any error so looks like this is a valid document. Also according to v3 schema exampels should have either payload or headers. If it has any one of those it should be valid.
@lovebug356 @PeteAudinate That's right, this example is correctly validated for v2, but not for v3.
@smoya Tested with:
@asyncapi/cli: v1.7.0@asyncapi/parser: v3.0.9
Yeah, I confirm there is no such rule in place in the Parser for v3 of the spec.
Can any of the maintainers of this repo move this issue to the parser-js repository? cc @Souvikns @magicmatatjahu @derberg
@smoya I can't
You can try on your side
I can't either, only transfer issues between glee, CLI and bundler.
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: