Skip to content

Commit cac33b6

Browse files
authored
fix(CLI): Allow optional data not to be passed (#1039)
1 parent 93ab5d0 commit cac33b6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

openapi-generator/templates/cli/api.handlebars

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ func init{{{nickname}}}() {
8888
{{/isPrimitiveType~}}
8989
{{#isModel~}}
9090
var {{paramName}} map[string]interface{}
91-
if err := json.Unmarshal([]byte(params.GetString("data")), &{{paramName}}); err != nil {
92-
HandleError(err)
93-
}
94-
if Config.Debug {
95-
fmt.Printf("%+v\n", {{paramName}})
91+
if params.IsSet("data") {
92+
if err := json.Unmarshal([]byte(params.GetString("data")), &{{paramName}}); err != nil {
93+
HandleError(err)
94+
}
95+
if Config.Debug {
96+
fmt.Printf("%+v\n", {{paramName}})
97+
}
9698
}
9799
{{/isModel~}}
98100
{{^isPrimitiveType}}{{^isModel}}

0 commit comments

Comments
 (0)