getkin / kin-openapi

OpenAPI 3.0 (and Swagger v2) implementation for Go (parsing, converting, validation, and more)
MIT License
2.53k stars 423 forks source link

Improve openapi3filter HTTP Response Code Accuracy #479

Open msvechla opened 2 years ago

msvechla commented 2 years ago

Hi,

Currently, the request validation always returns 400 Bad Request as the HTTP response. Would you be open to making the codes more configurable/accurate?

Especially in regards to the security authentication middleware, as 401 or 403 error codes would be a better fit for requests failing the validation by the AuthenticationFunc.

I would also be open to creating a PR if required.

Thanks a lot!

msvechla commented 2 years ago

Do you have an update or opinion about this?

fenollp commented 2 years ago

Yes feel free to open a PR. Finer / more configurable error codes / responses is always welcomed.