Improvement for oneof support#94
Improvement for oneof support#94boekkooi-impossiblecloud wants to merge 7 commits intobufbuild:mainfrom
Conversation
5414270 to
10e9606
Compare
|
Due to the upgrade to 1.14 in #98 and the addition of buf.validate.message.oneof i have rebased the PR and added the commits 331fc79, 10e9606 and 2972675. |
|
Hey @pkwarren Sorry to bug but is there any chance you could maybe have a look at this PR and let me know if this is an addition that would be welcome? Thanks in advance! |
|
Hey @boekkooi-impossiblecloud, thanks for the PR! I have some questions over here: #109 (comment) |
This allows for later usage of the fieldProperty name.
Ran `make lint` and resolved warnings/errors.
2972675 to
778e7dd
Compare
stefanvanburen
left a comment
There was a problem hiding this comment.
hi @boekkooi-impossiblecloud, thanks for the PR. mind getting it merged with main and I'll take another look?
| p.setDescription(entry.desc, entry.schema) | ||
|
|
||
| var oneOfRules []*validate.MessageOneofRule | ||
| rules, err := p.getMessageRules(entry.desc) |
There was a problem hiding this comment.
nit: should we just inline getMessageRules?
| if r, found := schema["required"]; found { | ||
| rs, ok := r.([]string) | ||
| if !ok { | ||
| return errors.New("invalid required field in schema") |
There was a problem hiding this comment.
is this an invariant from the generator? or should we at least print the actual type of r in the case of an error?
Good day,
While I was using the
protoc-gen-jsonschemaand it's generated schemas I noticed that oneOf validation was not happening for the on the JSON schema level.This PR implements the protobuf oneOf functionality and
(buf.validate.message).oneofusing the JSON Schema allOf and anyOf by using not in combination with required to exclude all other fields except for the one needed.Thanks for reviewing this PR! Please let me know what you think and have a great day!