Skip to content

Commit

Permalink
protoc-gen-{grpc-gateway,openapiv2}: add optional support
Browse files Browse the repository at this point in the history
Let `protoc` know that these generators support optional keywords. This
is by no means an implementation in `grpc-gateway` of the optional aware
generated code, it's just shielding of being considered as blockers in
code generation workflows.

Closes grpc-ecosystem#1278
  • Loading branch information
glerchundi committed Nov 25, 2020
1 parent 370d869 commit 53fbf87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/internal/proto/examplepb/a_bit_of_everything.proto
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ message ABitOfEverything {

// mark a field as readonly in Open API definition
string output_only_string_via_field_behavior_annotation = 39 [(google.api.field_behavior) = OUTPUT_ONLY];

// mark a field as optional
optional string optionl_string_value = 40;
}

// ABitOfEverythingRepeated is used to validate repeated path parameter functionality
Expand Down
3 changes: 2 additions & 1 deletion protoc-gen-openapiv2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func emitFiles(out []*descriptor.ResponseFile) {
for idx, item := range out {
files[idx] = item.CodeGeneratorResponse_File
}
emitResp(&pluginpb.CodeGeneratorResponse{File: files})
supportedFeatures := uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
emitResp(&pluginpb.CodeGeneratorResponse{SupportedFeatures: &supportedFeatures, File: files})
}

func emitError(err error) {
Expand Down

0 comments on commit 53fbf87

Please sign in to comment.