grpc-rest 0.1.2 → 0.1.4

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: c3dc93105554c8c92a3229f693ab0c93ed5833796ef7b7f11e94cb8821f2c425
4
- data.tar.gz: ac3ec407c674d16fb33e6bddccfa10b9e66859af3d5ecbad58d1ff2603e7c098
3
+ metadata.gz: b9c3044d8f6813a33030d336a91e4d86b4305a781d178d85a07e5e287ab22264
4
+ data.tar.gz: 659013b9ab51cd05f4e1b9570eeb71fb48f07992bd0f1eba80eb37aca1093921
5
5
  SHA512:
6
- metadata.gz: b1c05d823f083722774025bf8772d535b211b4ef01f3022baa92003a179ab2f3c1fcd6646c6b7eb5acf9ced1ff5abd3e962eea541ddfa7c0d9766bcc2649cb44
7
- data.tar.gz: c4c40a55b73429c7716ed2e6164c546f8d1c2e53030d6b1182475b66ec430590c637c691bac7af21294a62b39782a4ecc2d332c4afa68879cef4b803a170beb1
6
+ metadata.gz: 04ed1b2acf85c8ec4c069195dd1cd8711e7b68209dcf24cf62a60e832c89158364946d4da72012cc2b7bc037b6f2ac06df36a33a5a43b956e12e7dfe1b9d393b
7
+ data.tar.gz: 64f846bc132c121521c4ba1c8c1189bfed3ebfc4c1ee78473fac297aba84b1254037922a08859f165569a366c23df2b6da0ea391e08ef1e50c4430db713b9f86
data/CHANGELOG CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ # 0.1.4 - 2024-04-04
11
+ - Remove geo-admin hardcoded requirement.
12
+ - Use baked-in Protobuf initialization to support nested objects properly.
13
+
10
14
  # 0.1.0 - 2024-03-01
11
15
 
12
16
  * Initial release.
@@ -1,3 +1,3 @@
1
1
  module GrpcRest
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/grpc_rest.rb CHANGED
@@ -56,11 +56,6 @@ module GrpcRest
56
56
  sub_record.public_send(:"#{key}=", parameters.delete(key))
57
57
  end
58
58
  end
59
-
60
- # assign remaining parameters
61
- parameters.each do |k, v|
62
- assign_value(request, k, v)
63
- end
64
59
  end
65
60
 
66
61
  def error_msg(error)
@@ -16,7 +16,6 @@ type FileResult struct {
16
16
 
17
17
  type controller struct {
18
18
  ControllerName string
19
- ServiceFilePath string
20
19
  Methods []method
21
20
  ServiceName string
22
21
  FullServiceName string
@@ -41,7 +40,6 @@ type Route struct {
41
40
 
42
41
  var controllerTemplate = `
43
42
  require 'grpc_rest'
44
- require 'services/geo_admin/v1/test_services_pb'
45
43
  class {{.ControllerName}}Controller < ActionController::Base
46
44
  protect_from_forgery with: :null_session
47
45
 
@@ -60,8 +58,9 @@ class {{.ControllerName}}Controller < ActionController::Base
60
58
  {{$fullServiceName := .FullServiceName -}}
61
59
  {{range .Methods }}
62
60
  def {{.Name}}
63
- grpc_request = {{.RequestType}}.new
64
- GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["{{.Name}}"], "{{.Body}}", request.parameters)
61
+ fields = {{.RequestType}}.descriptor.to_a.map(&:name)
62
+ grpc_request = {{.RequestType}}.new(request.parameters.to_h.slice(*fields))
63
+ GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["{{.Name}}"], "{{.Body}}", request.parameters)
65
64
  render json: GrpcRest.send_request("{{$fullServiceName}}", "{{.Name}}", grpc_request)
66
65
  end
67
66
  {{end}}
@@ -74,7 +73,6 @@ func ProcessService(service *descriptorpb.ServiceDescriptorProto, pkg string) (F
74
73
  Methods: []method{},
75
74
  ServiceName: Classify(service.GetName()),
76
75
  ControllerName: Demodulize(service.GetName()),
77
- ServiceFilePath: FilePathify(pkg + "." + service.GetName()),
78
76
  FullServiceName: Classify(pkg + "." + service.GetName()),
79
77
  }
80
78
  for _, m := range service.GetMethod() {
@@ -1,6 +1,5 @@
1
1
 
2
2
  require 'grpc_rest'
3
- require 'services/geo_admin/v1/test_services_pb'
4
3
  class MyServiceController < ActionController::Base
5
4
  protect_from_forgery with: :null_session
6
5
 
@@ -23,20 +22,23 @@ class MyServiceController < ActionController::Base
23
22
  }.freeze
24
23
 
25
24
  def test
26
- grpc_request = Testdata::TestRequest.new
27
- GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["test"], "*", request.parameters)
25
+ fields = Testdata::TestRequest.descriptor.to_a.map(&:name)
26
+ grpc_request = Testdata::TestRequest.new(request.parameters.to_h.slice(*fields))
27
+ GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["test"], "*", request.parameters)
28
28
  render json: GrpcRest.send_request("Testdata::MyService", "test", grpc_request)
29
29
  end
30
30
 
31
31
  def test_2
32
- grpc_request = Testdata::TestRequest.new
33
- GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["test_2"], "second_record", request.parameters)
32
+ fields = Testdata::TestRequest.descriptor.to_a.map(&:name)
33
+ grpc_request = Testdata::TestRequest.new(request.parameters.to_h.slice(*fields))
34
+ GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["test_2"], "second_record", request.parameters)
34
35
  render json: GrpcRest.send_request("Testdata::MyService", "test_2", grpc_request)
35
36
  end
36
37
 
37
38
  def test_3
38
- grpc_request = Testdata::TestRequest.new
39
- GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["test_3"], "", request.parameters)
39
+ fields = Testdata::TestRequest.descriptor.to_a.map(&:name)
40
+ grpc_request = Testdata::TestRequest.new(request.parameters.to_h.slice(*fields))
41
+ GrpcRest.assign_params(grpc_request, METHOD_PARAM_MAP["test_3"], "", request.parameters)
40
42
  render json: GrpcRest.send_request("Testdata::MyService", "test_3", grpc_request)
41
43
  end
42
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grpc-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-04 00:00:00.000000000 Z
11
+ date: 2024-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc