asyncapi asyncApi2SchemaValidation does not allow string examples for other schema types
Describe the bug
The spectral rule asyncApi2SchemaValidation currently enforces that all examples have the same type as the schema type. However, we believe that there are cases in AsyncAPI, where it is needed to accept string examples regardless of the schema type.
To Reproduce
- Use the AsyncAPI document: https://github.com/asyncapi/spec/issues/1038#issuecomment-1969489452
- Open it in AsyncAPI studio (Or run the cli)
- Run
spectral lint --ruleset rule.yaml test.yaml - With
rule.yaml:extends: "spectral:asyncapi" - We had to change the version to
2.6.0, as the cli does not support3.0.0yet
- Run
- See the error:
66:11 error asyncapi-schema-examples "0" property type must be object components.schemas.io.github.springwolf.examples.kafka.dtos.XmlPayloadDto.examples[0]
Expected behavior No error/validation message
Screenshots N/A
Environment (remove any that are not applicable):
- Library version: develop
Additional context We are embedding xml and/or yaml as string in examples in an AsyncAPI (JSON) document.
Relates to https://github.com/asyncapi/spec/issues/1038
Update: Identical PR in parser-js has been merged: https://github.com/asyncapi/parser-js/pull/1007
EDIT: actually, it was only updated, not merged yet
:tada: This issue has been resolved in version 1.21.0 :tada:
The release is available on @stoplight/spectral-rulesets-1.21.0
Your semantic-release bot :package::rocket: