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 +4 -4
- data/haveapi-go-client.gemspec +1 -1
- data/lib/haveapi/go_client/parameters/typed.rb +9 -0
- data/lib/haveapi/go_client/version.rb +1 -1
- data/spec/integration/generator_spec.rb +72 -0
- data/template/action.go.erb +45 -21
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ceeb8d0d4bc76fb773c1f67cdc49be58d1e04569d256fd8b7613bbfd6eb655bf
|
|
4
|
+
data.tar.gz: 816f8ef02aff59ebfa107c8ff7a0debda73efe363b99f70f32f1e66d69563d40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a6dc5489b9e68b75faf32bc47f781df8b6df12a5f30058aa6dacc1ae5dd66c418075434f7f6fcd21d0563af2609357a0ac8c6c69fb9ca8efc878d0d7ffcf886
|
|
7
|
+
data.tar.gz: a8e5c3f45534a242438496370bbe226f25818303a3d492766397ee5df2cfef7f6bfd6bd03a11227b7b9d4f256e125aaf82325a7d8398488cf27c0f1ea5934425
|
data/haveapi-go-client.gemspec
CHANGED
|
@@ -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()
|
data/template/action.go.erb
CHANGED
|
@@ -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
|
-
|
|
577
|
-
<% action.metadata.global.input.parameters.each do |p| -%>
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
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
|
-
|
|
627
|
-
<% action.metadata.global.input.parameters.each do |p| -%>
|
|
628
|
-
|
|
629
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
25
|
+
version: 0.27.2
|
|
26
26
|
description: Go client generator
|
|
27
27
|
email:
|
|
28
28
|
- jakub.skokan@vpsfree.cz
|