twirp 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '07397331bd18c688d70740c3ad5cec2401103a325bab3331dda34d3072223c89'
4
- data.tar.gz: 684074c539bb00ddb32e814601378b6d3e0f967b48e8c758832a56a74ceba0a2
3
+ metadata.gz: 8558dba268ebf307651176d197204d1b803ec9429666e18f9831e597bdbb22f7
4
+ data.tar.gz: 8d2cde0d2dbaafa71ea9b2890ca459f010781f3b56c60976b2a41b5fbb69f931
5
5
  SHA512:
6
- metadata.gz: '079722ee218b74194884e10383fc9ebb53febf02e215d7fa001c14c864e3c2eff9fddee8079c29e06396a766901efab7e696c14d9f9e0afd6df1034a10e5aa56'
7
- data.tar.gz: d91d578d6cbd5245b38d5b1838892db43bc53730cdfb00391a1cad266d3193522625d87c3b5e2bfb0fc807bb90e6d1cd90063c95a139c5096ea4ef425106e2f7
6
+ metadata.gz: e64ccaf9a5f9005ff31c97fff51229b542492b9b6951b882836345828864173cc0f1b6f3b6831ef79f064e807438ed358f21a9cc1cc26d0c5516f095a69d91a0
7
+ data.tar.gz: 971687bef1e682359ac6a9bbfec2fdf1d4a4b44bd9a39b1732230de7aa592c4f12fc0d32001cd79cb874963f133dff832c3ebff8bf5bf32a5e0fa6d1b05e71c2
@@ -31,7 +31,7 @@ module Twirp
31
31
 
32
32
  def encode(msg_obj, msg_class, content_type)
33
33
  case content_type
34
- when JSON then msg_class.encode_json(msg_obj)
34
+ when JSON then msg_class.encode_json(msg_obj, emit_defaults: true)
35
35
  when PROTO then msg_class.encode(msg_obj)
36
36
  else raise ArgumentError.new("Invalid content_type")
37
37
  end
@@ -25,7 +25,7 @@ module Twirp
25
25
  already_exists: 409, # Conflict
26
26
  permission_denied: 403, # Forbidden
27
27
  unauthenticated: 401, # Unauthorized
28
- resource_exhausted: 403, # Forbidden
28
+ resource_exhausted: 429, # Too Many Requests
29
29
  failed_precondition: 412, # Precondition Failed
30
30
  aborted: 409, # Conflict
31
31
  out_of_range: 400, # Bad Request
@@ -12,5 +12,5 @@
12
12
  # permissions and limitations under the License.
13
13
 
14
14
  module Twirp
15
- VERSION = "1.5.0"
15
+ VERSION = "1.6.0"
16
16
  end
@@ -64,6 +64,15 @@ class ServiceTest < Minitest::Test
64
64
  assert_equal({"inches" => 10, "color" => "white"}, JSON.parse(body[0]))
65
65
  end
66
66
 
67
+ def test_successful_json_request_emit_defaults
68
+ rack_env = json_req "/example.Haberdasher/MakeHat", inches: 0 # default int value
69
+ status, headers, body = haberdasher_service.call(rack_env)
70
+
71
+ assert_equal 200, status
72
+ assert_equal 'application/json', headers['Content-Type']
73
+ assert_equal({"inches" => 0, "color" => "white"}, JSON.parse(body[0]))
74
+ end
75
+
67
76
  def test_successful_proto_request
68
77
  rack_env = proto_req "/example.Haberdasher/MakeHat", Example::Size.new(inches: 10)
69
78
  status, headers, body = haberdasher_service.call(rack_env)
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'bundler', '~> 1'
26
26
  spec.add_development_dependency 'minitest', '>= 5'
27
27
  spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rack', '>= 2.0.8'
28
+ spec.add_development_dependency 'rack', '>= 2.2.3'
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twirp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrus A. Forbes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-14 00:00:00.000000000 Z
12
+ date: 2020-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-protobuf
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.0.8
96
+ version: 2.2.3
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 2.0.8
103
+ version: 2.2.3
104
104
  description: Twirp is a simple RPC framework with protobuf service definitions. The
105
105
  Twirp gem provides native support for Ruby.
106
106
  email: