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: Use field name in json type schema if json tag is missing #2011

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

Conversation

erezrokah
Copy link
Member

Summary

I'm working on validating some data (internal issue https://github.com/cloudquery/cloudquery-issues/issues/2971) using the json type schema and noticed a bug (noticeable on AWS where structs don't have json tags).
We should not use the name transformer to get the name as it defaults to ToSnake when a json tag is missing.
Instead we should mimic the JSON marshaling default behavior to use the field name as is.

A better approach can be to create an instance of the type, marshal it to JSON, then use that for the names. Open to ideas how to do that using reflection, we a caveat that we might need to initialize it using non zero values that can be omitted


Use the following steps to ensure your PR is ready to be reviewed

  • Read the contribution guidelines 🧑‍🎓
  • Run go fmt to format your code 🖊
  • Lint your changes via golangci-lint run 🚨 (install golangci-lint here)
  • Update or add tests 🧪
  • Ensure the status checks below are successful ✅

@erezrokah erezrokah requested a review from a team as a code owner December 18, 2024 21:04
@erezrokah erezrokah requested review from k-rheinheimer and marianogappa and removed request for k-rheinheimer December 18, 2024 21:04
@github-actions github-actions bot added the fix label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant