haveapi-go-client 0.27.1 → 0.27.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b10b9259c694c973943eb57744455b88746275c842ac465c2ae8270d2047246
4
- data.tar.gz: 53b78ee429af5cb6490e909a84de83e4b9c596531f45fa31c51784394d18caf7
3
+ metadata.gz: ceeb8d0d4bc76fb773c1f67cdc49be58d1e04569d256fd8b7613bbfd6eb655bf
4
+ data.tar.gz: 816f8ef02aff59ebfa107c8ff7a0debda73efe363b99f70f32f1e66d69563d40
5
5
  SHA512:
6
- metadata.gz: 95a8aa35195c569f6a4a90d494c1775946dfca559d14fa21101e5bc293b3eeaec8890693a4ef4428773db4204e676efd799d3a2cfbf89e204a57069ab5289748
7
- data.tar.gz: 54b926ba7fdace81fff9e8ce48affebdc0006982e7ee9491f5c3730e57c293fd103b8cb5374e1b7e0384863a7aac8f025a509ef0685ff401ae1d524db2e93ad7
6
+ metadata.gz: 4a6dc5489b9e68b75faf32bc47f781df8b6df12a5f30058aa6dacc1ae5dd66c418075434f7f6fcd21d0563af2609357a0ac8c6c69fb9ca8efc878d0d7ffcf886
7
+ data.tar.gz: a8e5c3f45534a242438496370bbe226f25818303a3d492766397ee5df2cfef7f6bfd6bd03a11227b7b9d4f256e125aaf82325a7d8398488cf27c0f1ea5934425
@@ -18,5 +18,5 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'haveapi-client', '~> 0.27.1'
21
+ spec.add_dependency 'haveapi-client', '~> 0.27.2'
22
22
  end
@@ -6,6 +6,15 @@ module HaveAPI::GoClient
6
6
  !%w[Custom Resource].include?(desc[:type])
7
7
  end
8
8
 
9
+ def initialize(io, name, desc)
10
+ super
11
+ @required = desc[:required]
12
+ end
13
+
14
+ def nillable?
15
+ @required != true
16
+ end
17
+
9
18
  protected
10
19
 
11
20
  def do_resolve
@@ -1,5 +1,5 @@
1
1
  module HaveAPI
2
2
  module GoClient
3
- VERSION = '0.27.1'.freeze
3
+ VERSION = '0.27.2'.freeze
4
4
  end
5
5
  end
@@ -156,6 +156,54 @@ RSpec.describe HaveAPI::GoClient::Generator do
156
156
  }
157
157
  }
158
158
 
159
+ func TestEchoOptionalAcceptsNil(t *testing.T) {
160
+ c := newValidationClient()
161
+ req := c.Test.EchoOptional.Prepare()
162
+ in := req.NewInput()
163
+ in.SetDtNil(true)
164
+
165
+ resp, err := req.Call()
166
+ if err != nil {
167
+ t.Fatalf("request failed: %v", err)
168
+ }
169
+
170
+ if !resp.Status {
171
+ t.Fatalf("request failed: %s", resp.Message)
172
+ }
173
+
174
+ if !resp.Output.DtNil {
175
+ t.Fatalf("expected DtNil=true, got false")
176
+ }
177
+
178
+ if !resp.Output.DtProvided {
179
+ t.Fatalf("expected DtProvided=true, got false")
180
+ }
181
+ }
182
+
183
+ func TestEchoOptionalGetAcceptsNil(t *testing.T) {
184
+ c := newValidationClient()
185
+ req := c.Test.EchoOptionalGet.Prepare()
186
+ in := req.NewInput()
187
+ in.SetDtNil(true)
188
+
189
+ resp, err := req.Call()
190
+ if err != nil {
191
+ t.Fatalf("request failed: %v", err)
192
+ }
193
+
194
+ if !resp.Status {
195
+ t.Fatalf("request failed: %s", resp.Message)
196
+ }
197
+
198
+ if !resp.Output.DtNil {
199
+ t.Fatalf("expected DtNil=true, got false")
200
+ }
201
+
202
+ if !resp.Output.DtProvided {
203
+ t.Fatalf("expected DtProvided=true, got false")
204
+ }
205
+ }
206
+
159
207
  func TestEchoAcceptsValidInput(t *testing.T) {
160
208
  c := newValidationClient()
161
209
  req := c.Test.Echo.Prepare()
@@ -579,17 +579,25 @@ func (inv *<%= action.go_invocation_type %>) convertInputToQueryParams(ret map[s
579
579
  }
580
580
  <% end -%>
581
581
 
582
- <% if action.http_method == 'GET' && action.metadata.has_global_input? -%>
583
- func (inv *<%= action.go_invocation_type %>) convertMetaInputToQueryParams(ret map[string]string) {
584
- if inv.MetaInput != nil {
585
- <% action.metadata.global.input.parameters.each do |p| -%>
586
- if inv.IsMetaParameterSelected("<%= p.go_name %>") {
587
- ret["<%= action.resource.api_version.metadata_namespace %>[<%= p.name %>]"] = <% if p.go_in_type == 'string' %>inv.MetaInput.<%= p.go_name %><% else %>convert<%= p.go_in_type.capitalize %>ToString(inv.MetaInput.<%= p.go_name %>)<% end %>
582
+ <% if action.http_method == 'GET' && action.metadata.has_global_input? -%>
583
+ func (inv *<%= action.go_invocation_type %>) convertMetaInputToQueryParams(ret map[string]string) {
584
+ if inv.MetaInput != nil {
585
+ <% action.metadata.global.input.parameters.each do |p| -%>
586
+ if inv.IsMetaParameterSelected("<%= p.go_name %>") {
587
+ <% if p.nillable? -%>
588
+ if inv.IsMetaParameterNil("<%= p.go_name %>") {
589
+ ret["<%= action.resource.api_version.metadata_namespace %>[<%= p.name %>]"] = ""
590
+ } else {
591
+ ret["<%= action.resource.api_version.metadata_namespace %>[<%= p.name %>]"] = <% if p.go_in_type == 'string' %>inv.MetaInput.<%= p.go_name %><% else %>convert<%= p.go_in_type.capitalize %>ToString(inv.MetaInput.<%= p.go_name %>)<% end %>
592
+ }
593
+ <% else -%>
594
+ ret["<%= action.resource.api_version.metadata_namespace %>[<%= p.name %>]"] = <% if p.go_in_type == 'string' %>inv.MetaInput.<%= p.go_name %><% else %>convert<%= p.go_in_type.capitalize %>ToString(inv.MetaInput.<%= p.go_name %>)<% end %>
595
+ <% end -%>
596
+ }
597
+ <% end -%>
588
598
  }
589
- <% end -%>
590
599
  }
591
- }
592
- <% end -%>
600
+ <% end -%>
593
601
 
594
602
  <% if action.http_method != 'GET' && (action.has_input? || action.metadata.has_global_input?) -%>
595
603
  func (inv *<%= action.go_invocation_type %>) makeAllInputParams() *<%= action.go_request_type %> {
@@ -627,19 +635,27 @@ func (inv *<%= action.go_invocation_type %>) makeInputParams() map[string]interf
627
635
  }
628
636
  <% end -%>
629
637
 
630
- <% if action.metadata.has_global_input? -%>
631
- func (inv *<%= action.go_invocation_type %>) makeMetaInputParams() map[string]interface{} {
632
- ret := make(map[string]interface{})
638
+ <% if action.metadata.has_global_input? -%>
639
+ func (inv *<%= action.go_invocation_type %>) makeMetaInputParams() map[string]interface{} {
640
+ ret := make(map[string]interface{})
633
641
 
634
- if inv.MetaInput != nil {
635
- <% action.metadata.global.input.parameters.each do |p| -%>
636
- if inv.IsMetaParameterSelected("<%= p.go_name %>") {
637
- ret["<%= p.name %>"] = inv.MetaInput.<%= p.go_name %>
642
+ if inv.MetaInput != nil {
643
+ <% action.metadata.global.input.parameters.each do |p| -%>
644
+ if inv.IsMetaParameterSelected("<%= p.go_name %>") {
645
+ <% if p.nillable? -%>
646
+ if inv.IsMetaParameterNil("<%= p.go_name %>") {
647
+ ret["<%= p.name %>"] = nil
648
+ } else {
649
+ ret["<%= p.name %>"] = inv.MetaInput.<%= p.go_name %>
650
+ }
651
+ <% else -%>
652
+ ret["<%= p.name %>"] = inv.MetaInput.<%= p.go_name %>
653
+ <% end -%>
654
+ }
655
+ <% end -%>
638
656
  }
639
- <% end -%>
640
- }
641
657
 
642
- return ret
658
+ return ret
643
659
  }
644
660
  <% end -%>
645
661
  <% end -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi-go-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.1
4
+ version: 0.27.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.27.1
18
+ version: 0.27.2
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.27.1
25
+ version: 0.27.2
26
26
  description: Go client generator
27
27
  email:
28
28
  - jakub.skokan@vpsfree.cz