question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Global validation error model override

See original GitHub issue

It would be really cool to not only be able to override the validation_error_status globally but also the validation error model. e.g.

spectree.spec.SpecTree(..., validation_error_model=MyPydanticErrorModel)

What do you think? I would be happy to contribute.

BR

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dfkki123508commented, Sep 18, 2022

No this is not what I mean 😄 Sorry, for the confusion. I try to explain in a different way: This line adds the validation error to the responses which is later used in spec._generate_spec. So the api docs for every endpoint (not overriding 422 response) will look like this:

    responses:
      '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError.6a07bef'

So I want to tell spectree to use a custom model by default instead of the standard validation error.

Does this make it clearer? Thanks for your answers.

0reactions
dfkki123508commented, Nov 22, 2022

Awesome thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[FEATURE] Allow customization of validation error · Issue #1376
I'd like to globally customize validation errors by changing (overriding) the HTTPValidationError / ValidationError and the 422 status code. The ...
Read more >
Request Validation - Preventing Script Attacks - Microsoft Learn
This paper describes the request validation feature of ASP.NET where, by default, the application is prevented from processing unencoded ...
Read more >
Handling Errors - FastAPI
To override it, import the RequestValidationError and use it with @app. exception_handler(RequestValidationError) to decorate the exception handler. The ...
Read more >
Step 4. Add Validation and Error Handling
Add the Validate size operation to the hello-world project: ... Value: Click the fx button to change from literal mode to expression mode,...
Read more >
Validating form input - Angular
Every time the value of a form control changes, Angular runs validation and generates either a list of validation errors that results in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found