danielgtaylor / danielgtaylor/huma

Ability to remove default error schema?

Open
#880 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4.4k
Forks
285
Avg merge
40m
Merged PRs (30d)
1

Description

So, I notice that there's `ErrorModel` schema on my generated swagger. I narrow down the code to this code
```go
// defineErrors extracts possible error responses and defines them on the
// operation op.
func defineErrors(op *Operation, registry Registry) {
exampleErr := NewError(0, "")
errContentType := "application/json"
if ctf, ok := exampleErr.(ContentTypeFilter); ok {
errContentType = ctf.ContentType(errContentType)
}
errType := deref(reflect.TypeOf(exampleErr))
errSchema := registry.Schema(errType, true, getHint(errType, "", "Error"))
for _, code := range op.Errors {
op.Responses[strconv.Itoa(code)] = &Response{
Description: http.StatusText(code),
Content: map[string]*MediaType{
errContentType: {
Schema: errSchema,
},
},
}
}
if len(op.Responses) <= 1 && len(op.Errors) == 0 {
// No errors are defined, so set a default response.
op.Responses["default"] = &Response{
Description: "Error",
Content: map[string]*MediaType{
errContentType: {
Schema: errSchema,
},
},
}
}
}

```
In here, it enfore creation of the `ErrorModel` and `ErrorDetail`. Not mention of the `default` response too. It was everything under this block.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.