Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit d03da23

Browse files
authored
Merge pull request #155 from shomron/dont-point-to-range-variable
Fix scan for body parameter in ksonnet.parsePaths()
2 parents ed0796f + c848e79 commit d03da23

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ksonnet-gen/ksonnet/paths.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@ func parsePaths(apiSpec *spec.Swagger) (map[string]Component, error) {
1919
continue
2020
}
2121

22-
var body *spec.Parameter
22+
var body spec.Parameter
23+
var hasBody bool
2324
for _, param := range verb.Parameters {
2425
if param.Name == "body" {
25-
body = &param
26+
body = param // shallow copy
27+
hasBody = true
28+
break
2629
}
2730
}
2831

29-
if body == nil {
32+
if !hasBody {
3033
continue
3134
}
3235

36+
if body.Schema == nil {
37+
return nil, errors.Errorf("invalid body parameter - missing required field: schema")
38+
}
3339
ref := extractRef(*body.Schema)
3440

3541
component, exists, err := pathExtensionComponent(verb.Extensions)

0 commit comments

Comments
 (0)