-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
Little repro case of asyncapi schema related issues #158
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some hints. Hope they help!
Also, is there any reason you're using this library and ajv directly instead of using the JS AsyncAPI parser? It's doing this for you :)
function validate (schema, doc) { | ||
const ajv = new AJV({ | ||
allErrors: true, | ||
schemaId: "auto", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one should be:
schemaId: "auto", | |
schemaId: "id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmvilas Yep. That did it. Switching to "id" did it and solved the bundling issue. Thanks for the hint!
"oneOf": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/message" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the "through full dereferencing" test may be failing because there's a circular dependency on the schema here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed 😉
From what I read, Ajv seemed to never liked cirdular references (although the latest version seems to support them "between schemas"). In numerous issues @epoberezkin mentioned that starting from a serializable schema was the way to go. In that perspective, I had lots of hope for the bundle()
method. But it doesn't seem to work either.
@fmvilas Thanks!
Spectral runs its own schema validation mechanism in a as generic as possible way to support multiple schemas and plugging this library in as is (while respecting all Spectral use cases), wasn't easy to do. |
While working on stoplightio/spectral#974, I tried to leverage
json-schema-ref-parser
to process theasyncapi
schema.However, I've hit some walls. I'm sharing some repro cases.
Out of the three tests cases, two fails (full dereferencing and bundling) as the resulting schema cannot be processed by Ajv.
Is that expected? Did I do something wrong?
Any help or guidance would be greatly appreciated 😄
/cc @philsturgeon @fmvilas