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

fix types for Result::kind and Result::level #770

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

woodruffw
Copy link
Contributor

This PR tweaks the serde-sarif build.rs script slightly to introduce two new rewrites:

  • Result::kind is rewritten from Option<serde_json::Value> to Option<ResultKind>
  • Result::level is rewritten from Option<serde_json::Value> to Option<ResultLevel>

This is done because the underlying code generator (schemafy) has only limited enum support, and fails to produce these enums (ResultKind and ResultLevel) on its own. This library instead has its own defined versions of each, which then don't get used in the generated code.

There are a handful of other places where the generated code currently uses serde_json::Value, but I these two are the only ones currently causing issues for me 🙂 -- I'd be happy to send a more generalized patch if desired, however.

Longer term, a more general fix here might be switch from schemafy (which is unmaintained) to typify, which has better enum support. I didn't attempt that in this PR, since I think it'd be a much larger undertaking.

Fixes #738.

Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
@woodruffw
Copy link
Contributor Author

NB: I've updated the API usage as well -- there were a handful of places where string -> type conversions were being performed, and these are no longer necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResultKind and ResultLevel appear to serialize incorrectly
1 participant