gapic-generator 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/gem_templates/dockerfile.erb +1 -1
- data/gem_templates/entrypoint.erb +1 -0
- data/lib/gapic/generator/version.rb +1 -1
- data/lib/gapic/presenters/field_presenter.rb +12 -0
- data/lib/gapic/presenters/gem_presenter.rb +1 -1
- data/lib/gapic/presenters/method_presenter.rb +5 -0
- data/lib/gapic/runner.rb +3 -1
- data/lib/gapic/schema/wrappers.rb +11 -1
- data/lib/google/protobuf/compiler/plugin.pb.rb +5 -1
- data/lib/google/protobuf/descriptor.pb.rb +1 -0
- data/templates/default/gem/gemfile.erb +0 -3
- data/templates/default/service/test/method/_bidi.erb +6 -0
- data/templates/default/service/test/method/_client.erb +6 -0
- data/templates/default/service/test/method/_normal.erb +6 -0
- data/templates/default/service/test/method/_server.erb +6 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78e591a0a5e9a24086ccfcf3227d7fe20dd2c0732f6ff7e4230b81ee48d0bcb6
|
4
|
+
data.tar.gz: 48b3b285796cd0bc3452ebf15797a8a1c54941aa79e4781588abc7f90b3aee8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2095d8bd87701b4b229a4f7c3c4ec2623a76b9c11c076068c5653d084881c68c44f23e96c9310f329bd2f64d3a91dd929a10656a1b19677e125d6555e70105cf
|
7
|
+
data.tar.gz: faeb9756320e9863dcede6634bd03c6024798871e3c8ebf083c65eb3bc917933806365d292303b436088b3371c43e86c5992e2cd1fdfed7465cd3f22e7562468
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Release History for gapic-generator
|
2
2
|
|
3
|
+
### 0.6.2 / 2020-06-18
|
4
|
+
|
5
|
+
* Support for the proto3_optional
|
6
|
+
* Fixed an issue where tests for the oneof fields were not generating correctly
|
7
|
+
* Removed ruby <2.5 pin for the protobuf dependency since new protobuf supports it again
|
8
|
+
* Generated libraries now depend on gapic-common 0.3
|
9
|
+
|
3
10
|
### 0.6.1 / 2020-06-16
|
4
11
|
|
5
12
|
* Add auto-generated disclaimer to generated tests.
|
@@ -30,7 +30,7 @@ COPY --from=gcr.io/gapic-images/api-common-protos:beta /protos/ /workspace/commo
|
|
30
30
|
COPY --from=builder /workspace/*.gem /workspace/
|
31
31
|
|
32
32
|
# Install the subgenerator and other needed tools.
|
33
|
-
RUN gem install grpc-tools gapic-generator-<%= gem_name %>.gem \
|
33
|
+
RUN gem install --pre grpc-tools gapic-generator-<%= gem_name %>.gem \
|
34
34
|
&& rm gapic-generator-<%= gem_name %>.gem \
|
35
35
|
&& mkdir -p --mode=777 /.cache
|
36
36
|
|
@@ -80,6 +80,10 @@ module Gapic
|
|
80
80
|
@field.enum?
|
81
81
|
end
|
82
82
|
|
83
|
+
def proto3_optional?
|
84
|
+
@field.proto3_optional?
|
85
|
+
end
|
86
|
+
|
83
87
|
def repeated?
|
84
88
|
@field.repeated?
|
85
89
|
end
|
@@ -88,6 +92,14 @@ module Gapic
|
|
88
92
|
@field.map?
|
89
93
|
end
|
90
94
|
|
95
|
+
def oneof?
|
96
|
+
@field.oneof?
|
97
|
+
end
|
98
|
+
|
99
|
+
def oneof_name
|
100
|
+
@message.oneof_decl[@field.oneof_index].name
|
101
|
+
end
|
102
|
+
|
91
103
|
protected
|
92
104
|
|
93
105
|
def field_doc_types field, output
|
@@ -174,7 +174,7 @@ module Gapic
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def dependencies
|
177
|
-
deps = { "gapic-common" => "~> 0.
|
177
|
+
deps = { "gapic-common" => "~> 0.3" }
|
178
178
|
deps["grpc-google-iam-v1"] = [">= 0.6.10", "< 2.0"] if iam_dependency?
|
179
179
|
extra_deps = gem_config :extra_dependencies
|
180
180
|
deps.merge! extra_deps if extra_deps
|
@@ -92,6 +92,11 @@ module Gapic
|
|
92
92
|
have_oneof = []
|
93
93
|
|
94
94
|
@method.input.fields.each do |field|
|
95
|
+
unless field.oneof?
|
96
|
+
selected_fields << field
|
97
|
+
next
|
98
|
+
end
|
99
|
+
|
95
100
|
idx = field.oneof_index
|
96
101
|
selected_fields << field unless have_oneof.include? idx
|
97
102
|
have_oneof << idx
|
data/lib/gapic/runner.rb
CHANGED
@@ -48,8 +48,10 @@ module Gapic
|
|
48
48
|
output_files = generator.new(api).generate
|
49
49
|
|
50
50
|
# Create and write the response
|
51
|
-
Google::Protobuf::Compiler::CodeGeneratorResponse.new \
|
51
|
+
response = Google::Protobuf::Compiler::CodeGeneratorResponse.new \
|
52
52
|
file: output_files
|
53
|
+
response.supported_features = Google::Protobuf::Compiler::CodeGeneratorResponse::FEATURE_PROTO3_OPTIONAL
|
54
|
+
response
|
53
55
|
end
|
54
56
|
|
55
57
|
# Run protoc generation.
|
@@ -655,6 +655,15 @@ module Gapic
|
|
655
655
|
field_behavior.include? Google::Api::FieldBehavior::OPTIONAL
|
656
656
|
end
|
657
657
|
|
658
|
+
# Denotes a field as a part of oneof.
|
659
|
+
# oneof_index is an int field so it'll be 0 by default for every field
|
660
|
+
# and an index in the message's oneof table for the oneof fields
|
661
|
+
# but since the indexes in the message's oneof table start with 0 as well
|
662
|
+
# we need this to determine whether the field is a part of the oneof
|
663
|
+
def oneof?
|
664
|
+
@descriptor.field? :oneof_index
|
665
|
+
end
|
666
|
+
|
658
667
|
# Denotes a field as required. This indicates that the field **must** be
|
659
668
|
# provided as part of the request, and failure to do so will cause an
|
660
669
|
# error (usually `INVALID_ARGUMENT`).
|
@@ -731,7 +740,8 @@ module Gapic
|
|
731
740
|
:default_value,
|
732
741
|
:oneof_index,
|
733
742
|
:json_name,
|
734
|
-
:options
|
743
|
+
:options,
|
744
|
+
:proto3_optional?
|
735
745
|
)
|
736
746
|
end
|
737
747
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
##
|
4
|
-
# This file
|
4
|
+
# This file was auto-generated initially but now is hand-edited to add support
|
5
|
+
# for response features and proto3_optional
|
5
6
|
#
|
6
7
|
require 'protobuf'
|
7
8
|
|
@@ -54,6 +55,8 @@ module Google
|
|
54
55
|
end
|
55
56
|
|
56
57
|
class CodeGeneratorResponse
|
58
|
+
FEATURE_PROTO3_OPTIONAL = 1
|
59
|
+
|
57
60
|
class File
|
58
61
|
optional :string, :name, 1
|
59
62
|
optional :string, :insertion_point, 2
|
@@ -61,6 +64,7 @@ module Google
|
|
61
64
|
end
|
62
65
|
|
63
66
|
optional :string, :error, 1
|
67
|
+
optional :int32, :supported_features, 2
|
64
68
|
repeated ::Google::Protobuf::Compiler::CodeGeneratorResponse::File, :file, 15
|
65
69
|
end
|
66
70
|
|
@@ -93,6 +93,12 @@ def test_<%= method.name %>
|
|
93
93
|
<%- else -%>
|
94
94
|
assert_equal <%= field.default_value %>, r.<%= field.name %>
|
95
95
|
<%- end -%>
|
96
|
+
<%- if field.oneof? && !field.proto3_optional? -%>
|
97
|
+
assert_equal :<%= field.name %>, r.<%= field.oneof_name %>
|
98
|
+
<%- end -%>
|
99
|
+
<%- if field.proto3_optional? -%>
|
100
|
+
assert r.has_<%= field.name %>?
|
101
|
+
<%- end -%>
|
96
102
|
<%- end -%>
|
97
103
|
end
|
98
104
|
end
|
@@ -77,6 +77,12 @@ def test_<%= method.name %>
|
|
77
77
|
<%- else -%>
|
78
78
|
assert_equal <%= field.default_value %>, r.<%= field.name %>
|
79
79
|
<%- end -%>
|
80
|
+
<%- if field.oneof? && !field.proto3_optional? -%>
|
81
|
+
assert_equal :<%= field.name %>, r.<%= field.oneof_name %>
|
82
|
+
<%- end -%>
|
83
|
+
<%- if field.proto3_optional? -%>
|
84
|
+
assert r.has_<%= field.name %>?
|
85
|
+
<%- end -%>
|
80
86
|
<%- end -%>
|
81
87
|
end
|
82
88
|
end
|
@@ -26,6 +26,12 @@ def test_<%= method.name %>
|
|
26
26
|
<%- else -%>
|
27
27
|
assert_equal <%= field.default_value %>, request.<%= field.name %>
|
28
28
|
<%- end -%>
|
29
|
+
<%- if field.oneof? && !field.proto3_optional? -%>
|
30
|
+
assert_equal :<%= field.name %>, request.<%= field.oneof_name %>
|
31
|
+
<%- end -%>
|
32
|
+
<%- if field.proto3_optional? -%>
|
33
|
+
assert request.has_<%= field.name %>?
|
34
|
+
<%- end -%>
|
29
35
|
<%- end -%>
|
30
36
|
refute_nil options
|
31
37
|
end
|
@@ -24,6 +24,12 @@ def test_<%= method.name %>
|
|
24
24
|
<%- else -%>
|
25
25
|
assert_equal <%= field.default_value %>, request.<%= field.name %>
|
26
26
|
<%- end -%>
|
27
|
+
<%- if field.oneof? && !field.proto3_optional? -%>
|
28
|
+
assert_equal :<%= field.name %>, request.<%= field.oneof_name %>
|
29
|
+
<%- end -%>
|
30
|
+
<%- if field.proto3_optional? -%>
|
31
|
+
assert request.has_<%= field.name %>?
|
32
|
+
<%- end -%>
|
27
33
|
<%- end -%>
|
28
34
|
refute_nil options
|
29
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gapic-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernest Landrito
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-06-
|
13
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -74,14 +74,14 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 1.30.0.pre1
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: 1.30.0.pre1
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: minitest
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|