Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncapi asyncApi2SchemaValidation does not allow string examples for other schema types #2624

Closed
timonback opened this issue May 24, 2024 · 1 comment · Fixed by #2625
Closed
Labels
AsyncAPI Issues related to the AsyncAPI ruleset triaged

Comments

@timonback
Copy link
Contributor

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: Allow plain string in Message Example Object field payload for non-json payloads (like xml, yaml) asyncapi/spec#1038 (comment)
  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 asyncapi/spec#1038

@timonback
Copy link
Contributor Author

timonback commented Jun 21, 2024

Update: Identical PR in parser-js has been merged: asyncapi/parser-js#1007

EDIT: actually, it was only updated, not merged yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AsyncAPI Issues related to the AsyncAPI ruleset triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants