forked from loafle/openapi-generator-original
[go-server] add field name in parsing error messages (#18533)
Currently when a parsing rule of a field is not respected (eg: min/max value, required, ...), the api only returns an error message without providing the field name to help the user to fix the request. This commit add the field name to the error message to help the user of the API.
This commit is contained in:
@@ -190,7 +190,7 @@ func (c *UserAPIController) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
WithParse[bool](parseBool),
|
||||
)
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
c.errorHandler(w, r, &ParsingError{Param: "boolean_test", Err: err}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ func (c *UserAPIController) LoginUser(w http.ResponseWriter, r *http.Request) {
|
||||
WithParse[bool](parseBool),
|
||||
)
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
c.errorHandler(w, r, &ParsingError{Param: "boolean_test", Err: err}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user