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 +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 +48 -0
- data/template/action.go.erb +35 -19
- 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
|
@@ -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()
|
data/template/action.go.erb
CHANGED
|
@@ -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
|
-
|
|
585
|
-
<% action.metadata.global.input.parameters.each do |p| -%>
|
|
586
|
-
|
|
587
|
-
|
|
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
|
-
|
|
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
|
-
|
|
635
|
-
<% action.metadata.global.input.parameters.each do |p| -%>
|
|
636
|
-
|
|
637
|
-
|
|
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
|
-
|
|
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.
|
|
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
|