-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
refactor: add RAML Schema Parser #577
refactor: add RAML Schema Parser #577
Conversation
const jsonModel = await r2j.dt2js(payload, 'tmpType', { draft: '06' }); | ||
const convertedType = jsonModel.definitions.tmpType; | ||
|
||
message['x-parser-original-schema-format'] = input.schemaFormat || input.defaultSchemaFormat; |
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.
Same as #576 (comment)
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 wrote comment about that in PR for AVRO :) We will handle that in one place.
5c19383
to
e3772ba
Compare
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.
Great. I left two comments, please refer to them and we can merge that PR :)
const jsonModel = await r2j.dt2js(payload, 'tmpType', { draft: '06' }); | ||
const convertedType = jsonModel.definitions.tmpType; | ||
|
||
message['x-parser-original-schema-format'] = input.schemaFormat || input.defaultSchemaFormat; |
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 wrote comment about that in PR for AVRO :) We will handle that in one place.
report.results.forEach(result => { | ||
validateResult.push({ | ||
message: result.message, | ||
path: input.path, // Info provided by the RAML parser doesn't provide a real path to the error. |
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.
In the custom parsers path of single error should point to from perspective of given payload - in other words, payload should be treated as root of error, we will concatenate error path in one place, concatenate path of schema + path of error, so here you should return empty array.
path: input.path, // Info provided by the RAML parser doesn't provide a real path to the error. | |
path: [] // Info provided by the RAML parser doesn't provide a real path to the error. |
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.
Let's say input.path
value is: ["channels", "myChannel", "publish", "message", "payload"]
, the behaviour will be different that https:/asyncapi/parser-js/pull/578/files#r952869403
I think I'm missing something.
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.
But there you operate on error results, in mentioned comment you create mock data for testing. .path
of input is location on which data you operate some logic, error.path
is path of the error, but from .path
point of view - it's a local path that we will merge after validation 😄
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.
Changed!
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.
One thing, rest is awesome! :)
message.payload = convertedType; | ||
delete message.schemaFormat; | ||
} catch (e) { | ||
console.error(e); |
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.
TBH I don't think so that we need that console.error. We will try catch this inside customOperations
:)
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.
Removed!
Kudos, SonarCloud Quality Gate passed! |
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.
LGTM! 🚀 Should we wait for review of parser's maintainers?
We can merge now as we have one approval from a code owner. |
/rtm |
Description
This PR does the following:
validate()
method).Related issue(s)
#480