File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
package models
2
2
3
- import "encoding/json"
3
+ import (
4
+ "encoding/json"
5
+ "errors"
6
+ )
4
7
5
8
{{ ((definition .description | caseUcfirst ) ~ " Model" ) | godocComment }}
6
9
type {{ definition .name | caseUcfirst }} struct {
@@ -21,7 +24,11 @@ func (model {{ definition.name | caseUcfirst }}) New(data []byte) *{{ definition
21
24
{%~ if definition .additionalProperties %}
22
25
// Use this method to get response in desired type
23
26
{%~ endif %}
24
- func (model *{{ definition .name | caseUcfirst }}) Decode(value *any) error {
27
+ func (model *{{ definition .name | caseUcfirst }}) Decode(value interface{}) error {
28
+ if len(model.data) < = 0 {
29
+ return errors.New("method Decode() cannot be used on nested structs.")
30
+ }
31
+
25
32
err := json.Unmarshal(model.data, value)
26
33
if err != nil {
27
34
return err
You can’t perform that action at this time.
0 commit comments