-
Notifications
You must be signed in to change notification settings - Fork 4
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
JSON Schema: Ignore fields via comment #14
Conversation
should the fields really be ignored? Or somehow less prominent in the json schema. I am pretty sure it will show you an error if you try to use a field that is not listed in the json schema. |
@Alfus are you thinking of something more explicit like https://json-schema.org/understanding-json-schema/reference/combining#not where you can exclude specific keys? but also, this seems like a nice property in general where you want the jsonschema to be a subset of the protos? |
I am suggesting the field get listed in the schema, but not have docs, or maybe json schema has a 'hid' option so it doen't suggest the field, but will still validate it, if present. |
The goal here is for a config file that supports some internal-only (mostly testing or experimental) properties, but hides them from end users. Some options:
|
My vote would be option 4 (current implementation), followed closely by a plugin option to get this out of the proto definitions, something like In terms of My only other suggestion is let's give it a try, get some hands-on experience, report feedback and tweak it as we go. |
Kept it as-is for now. We can revisit with a more robust solution after we see where this all lands. |
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'd suggest removing the readme changes, and keeping this as an undocumented "internal feature". Otherwise lgtm as we buy us time to iterate on this.
This patch enables having fields ignored in the JSON Schema generation via a comment containing
jsonschema:ignore
(in either a leading or trailing comment).A comment here is expedient, but not ideal as a long-term strategy. Would be much better as a custom option. This also has no impact on PubSub generation, though could presumably be extended to support that as well.
Part of this required changes to the golden tests as source location info (read: comments) aren't preserved in the reflection descriptors by the Go protobuf library (or any of the official ones for that matter). As a result, comments have now appeared in the
input.json
and impacted golden tests.Holding off documenting until this strategy is approved.