forked from loafle/openapi-generator-original
fix(go-server): Allow optional request bodies (#16579)
* fix(go-server): Allow optional request bodies Closes #16578 * chore: Run scripts * chore: Remove unnecessary whitespace change * fix: Use correct error
This commit is contained in:
parent
8c8be7482b
commit
352182a7b9
@ -3,6 +3,12 @@ package {{packageName}}
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
{{#isBodyParam}}
|
||||
{{^required}}
|
||||
"errors"
|
||||
"io"
|
||||
{{/required}}
|
||||
{{/isBodyParam}}
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@ -403,7 +409,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
|
||||
{{^isAdditionalPropertiesTrue}}
|
||||
d.DisallowUnknownFields()
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
if err := d.Decode(&{{paramName}}Param); err != nil {
|
||||
if err := d.Decode(&{{paramName}}Param); err != nil {{^required}}&& !errors.Is(err, io.EOF) {{/required}}{
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user