haveapi-go-client 0.27.0 → 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: bb661e4d9dd5ab5b29d5d3b63af4b37a486848e0623a6e34ac41f53f0a0feebe
4
- data.tar.gz: 485e7d815e181bf209d541a0eb63c305acd79440cba6144812263b25108369de
3
+ metadata.gz: ceeb8d0d4bc76fb773c1f67cdc49be58d1e04569d256fd8b7613bbfd6eb655bf
4
+ data.tar.gz: 816f8ef02aff59ebfa107c8ff7a0debda73efe363b99f70f32f1e66d69563d40
5
5
  SHA512:
6
- metadata.gz: c6ff55c1c5d592a79c5052df6ee2ea9311e0039b7d37068d9048d592ee2fe0b63913c9dca088387abf57a1937b015a75c4bf3c664a20aac9875f62e2d88236d3
7
- data.tar.gz: 06014c3863378caf51e02c6b6be0d919f740d6659974c185915ec89a8b0a4bd07434e625481599704ead36f3565e718fd0817462d6400462a0dcda01abd1097d
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.0'
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.0'.freeze
3
+ VERSION = '0.27.2'.freeze
4
4
  end
5
5
  end
@@ -132,6 +132,78 @@ RSpec.describe HaveAPI::GoClient::Generator do
132
132
  }
133
133
  }
134
134
 
135
+ func TestEchoResourceOptionalAcceptsNil(t *testing.T) {
136
+ c := newValidationClient()
137
+ req := c.Test.EchoResourceOptional.Prepare()
138
+ in := req.NewInput()
139
+ in.SetProjectNil(true)
140
+
141
+ resp, err := req.Call()
142
+ if err != nil {
143
+ t.Fatalf("request failed: %v", err)
144
+ }
145
+
146
+ if !resp.Status {
147
+ t.Fatalf("request failed: %s", resp.Message)
148
+ }
149
+
150
+ if !resp.Output.ProjectNil {
151
+ t.Fatalf("expected ProjectNil=true, got false")
152
+ }
153
+
154
+ if !resp.Output.ProjectProvided {
155
+ t.Fatalf("expected ProjectProvided=true, got false")
156
+ }
157
+ }
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
+
135
207
  func TestEchoAcceptsValidInput(t *testing.T) {
136
208
  c := newValidationClient()
137
209
  req := c.Test.Echo.Prepare()
@@ -562,26 +562,42 @@ func (resp *<%= action.go_response_type %>) CancelOperation() (*ActionActionStat
562
562
  <% if action.http_method == 'GET' && action.has_input? -%>
563
563
  func (inv *<%= action.go_invocation_type %>) convertInputToQueryParams(ret map[string]string) {
564
564
  if inv.Input != nil {
565
- <% action.input.parameters.each do |p| -%>
565
+ <% action.input.parameters.each do |p| -%>
566
566
  if inv.IsParameterSelected("<%= p.go_name %>") {
567
+ <% if p.nillable? -%>
568
+ if inv.IsParameterNil("<%= p.go_name %>") {
569
+ ret["<%= action.input.namespace %>[<%= p.name %>]"] = ""
570
+ } else {
571
+ ret["<%= action.input.namespace %>[<%= p.name %>]"] = <% if p.go_in_type == 'string' %>inv.Input.<%= p.go_name %><% else %>convert<%= p.go_in_type.capitalize %>ToString(inv.Input.<%= p.go_name %>)<% end %>
572
+ }
573
+ <% else -%>
567
574
  ret["<%= action.input.namespace %>[<%= p.name %>]"] = <% if p.go_in_type == 'string' %>inv.Input.<%= p.go_name %><% else %>convert<%= p.go_in_type.capitalize %>ToString(inv.Input.<%= p.go_name %>)<% end %>
575
+ <% end -%>
568
576
  }
569
- <% end -%>
577
+ <% end -%>
570
578
  }
571
579
  }
572
580
  <% end -%>
573
581
 
574
- <% if action.http_method == 'GET' && action.metadata.has_global_input? -%>
575
- func (inv *<%= action.go_invocation_type %>) convertMetaInputToQueryParams(ret map[string]string) {
576
- if inv.MetaInput != nil {
577
- <% action.metadata.global.input.parameters.each do |p| -%>
578
- if inv.IsMetaParameterSelected("<%= p.go_name %>") {
579
- 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 -%>
580
598
  }
581
- <% end -%>
582
599
  }
583
- }
584
- <% end -%>
600
+ <% end -%>
585
601
 
586
602
  <% if action.http_method != 'GET' && (action.has_input? || action.metadata.has_global_input?) -%>
587
603
  func (inv *<%= action.go_invocation_type %>) makeAllInputParams() *<%= action.go_request_type %> {
@@ -619,19 +635,27 @@ func (inv *<%= action.go_invocation_type %>) makeInputParams() map[string]interf
619
635
  }
620
636
  <% end -%>
621
637
 
622
- <% if action.metadata.has_global_input? -%>
623
- func (inv *<%= action.go_invocation_type %>) makeMetaInputParams() map[string]interface{} {
624
- 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{})
625
641
 
626
- if inv.MetaInput != nil {
627
- <% action.metadata.global.input.parameters.each do |p| -%>
628
- if inv.IsMetaParameterSelected("<%= p.go_name %>") {
629
- 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 -%>
630
656
  }
631
- <% end -%>
632
- }
633
657
 
634
- return ret
658
+ return ret
635
659
  }
636
660
  <% end -%>
637
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.0
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.0
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.0
25
+ version: 0.27.2
26
26
  description: Go client generator
27
27
  email:
28
28
  - jakub.skokan@vpsfree.cz