-
Notifications
You must be signed in to change notification settings - Fork 149
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
feat(go): Improve dynamic snippets error reporting #5099
Conversation
throw new Error(`Expected discriminant value to be a string but got: ${JSON.stringify(discriminantValue)}`); | ||
this.errors.add({ | ||
severity: Severity.Critical, | ||
message: `Expected discriminant value to be a string but got: ${JSON.stringify(discriminantValue)}` |
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.
${JSON.stringify(discriminantValue)}
this might be a little tough for anyone to render in a pretty way -- maybe we just add the type of discriminantValue
?
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.
Good call, happy to adjust the message 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.
Approving to unblock, couple things crossed my mind:
- If we add
JSON.stringify()
in the error messages, its going to be hard for a consumer to render in a pretty way. - It would be nice to decouple validation from generator specific code (i.e. python/typescript should not have to worry about dealing with validation)
- Reimplementing validation will never be as fully-featured as a third party lib that'll take things like
min
,max
,regex
into account as well (so still pushing json schema here)
Still great to have this since we are going from a world with no validation to real validation. Curious for your thoughts on the above!
|
This adds the
ErrorReporter
into the dynamic snippet generator's core flow. With this, we collect all errors that occur during snippet generation, but continue to compose the snippet as best we can (leveraginggo.TypeInstantiation.nop
as needed).In the future, we plan to supplement this validation with the help of JSON schema, but this at least builds out the hand-crafted solution that will be used by the regions of the snippet that won't be covered by JSON schema (e.g. query parameters, headers, etc).