spectral icon indicating copy to clipboard operation
spectral copied to clipboard

asyncapi asyncApi2SchemaValidation does not allow string examples for other schema types

Open timonback opened this issue 1 year ago • 1 comments

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

  1. Use the AsyncAPI document: https://github.com/asyncapi/spec/issues/1038#issuecomment-1969489452
  2. Open it in AsyncAPI studio (Or run the cli)
    1. Run spectral lint --ruleset rule.yaml test.yaml
    2. With rule.yaml: extends: "spectral:asyncapi"
    3. We had to change the version to 2.6.0, as the cli does not support 3.0.0 yet
  3. 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

timonback avatar May 24 '24 16:05 timonback

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

timonback avatar Jun 21 '24 11:06 timonback

: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:

stoplight-bot avatar Nov 12 '24 02:11 stoplight-bot