Repository navigation
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.
I wrote comment about that in PR for AVRO :) We will handle that in one place.
5c19383 to
e3772ba
Compare
magicmatatjahu
left a comment
There was a problem hiding this comment.
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.
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.
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.
Let's say input.path value is: ["channels", "myChannel", "publish", "message", "payload"], the behaviour will be different that https://github.com/asyncapi/parser-js/pull/578/files#r952869403
I think I'm missing something.
There was a problem hiding this comment.
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 😄
magicmatatjahu
left a comment
There was a problem hiding this comment.
One thing, rest is awesome! :)
| message.payload = convertedType; | ||
| delete message.schemaFormat; | ||
| } catch (e) { | ||
| console.error(e); |
There was a problem hiding this comment.
TBH I don't think so that we need that console.error. We will try catch this inside customOperations :)
|
Kudos, SonarCloud Quality Gate passed! |
magicmatatjahu
left a comment
There was a problem hiding this comment.
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