这是indexloc提供的服务,不要输入任何密码
Skip to content

[Question]: Is it possible to change default HTTP Status Code on Validation Error? #561

@superstas

Description

@superstas

Hi there!

I wonder how to change the default HTTP Status Code from 422 ( from here ) to smth custom ( in our case, it's 400 ).

With the current capabilities, I can customize almost everything in the default validation error by overriding huma.NewError function and get what I need:

        HTTP/1.1 422 Unprocessable Entity
        Connection: close
        Content-Type: application/problem+json
        
        {
          "type": "bad-request/validation",
          "title": "Bad Request",
          "status": 400,
          "detail": "Validation failed",
          "errors": [
            {
              "message": "required header parameter is missing",
              "location": "header.X-Custom-Header",
              "value": ""
            }
          ]
        }

However, I couldn't find a way to customize the HTTP Status Code for this case.
Could you please help me understand whether it's possible? If not, what do you think about implementing it? Does it make any sense?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions