Commit e53ed1d1 authored by fabian serin's avatar fabian serin
Browse files

Fix validation error model

parent 2f6f3d63
Pipeline #61933 failed with stages
in 19 minutes and 32 seconds
...@@ -17,7 +17,7 @@ from typing import Union ...@@ -17,7 +17,7 @@ from typing import Union
from fastapi.exceptions import RequestValidationError from fastapi.exceptions import RequestValidationError
from fastapi.encoders import jsonable_encoder from fastapi.encoders import jsonable_encoder
from fastapi.openapi.constants import REF_PREFIX from fastapi.openapi.constants import REF_PREFIX
from fastapi.openapi.utils import validation_error_response_definition from fastapi.openapi.utils import validation_error_response_definition, validation_error_definition
from pydantic import ValidationError from pydantic import ValidationError
from starlette.requests import Request from starlette.requests import Request
from starlette.responses import JSONResponse from starlette.responses import JSONResponse
...@@ -37,6 +37,18 @@ async def http422_error_handler( ...@@ -37,6 +37,18 @@ async def http422_error_handler(
return JSONResponse(content=jsonable_encoder({"errors": exc.errors()}), status_code=HTTP_422_UNPROCESSABLE_ENTITY) return JSONResponse(content=jsonable_encoder({"errors": exc.errors()}), status_code=HTTP_422_UNPROCESSABLE_ENTITY)
validation_error_definition["properties"] = {
"loc": {
"title": "Location", "type": "array", "items": {
"oneOf": [
{"type": "string"},
{"type": "integer"}
]
}
},
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
}
validation_error_response_definition["properties"] = { validation_error_response_definition["properties"] = {
"errors": { "errors": {
"title": "Errors", "title": "Errors",
......
...@@ -3394,7 +3394,14 @@ ...@@ -3394,7 +3394,14 @@
"properties": { "properties": {
"loc": { "loc": {
"items": { "items": {
"type": "string" "oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}, },
"title": "Location", "title": "Location",
"type": "array" "type": "array"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment