]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:bug: Add ValidationError schema even if only bodies
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 10 Dec 2018 20:28:47 +0000 (00:28 +0400)
committerSebastián Ramírez <tiangolo@gmail.com>
Mon, 10 Dec 2018 20:30:15 +0000 (00:30 +0400)
are declared in the defined endpoints

fastapi/openapi/utils.py

index 3e445d6150afdadd1dbc27001c3a9a73a7ed8258..6f490a5d0cb1295090649499fe5ceb1ae7ffc610 100644 (file)
@@ -172,6 +172,11 @@ def get_openapi_path(
             )
             if request_body_oai:
                 operation["requestBody"] = request_body_oai
+                if "ValidationError" not in definitions:
+                    definitions["ValidationError"] = validation_error_definition
+                    definitions[
+                        "HTTPValidationError"
+                    ] = validation_error_response_definition
         status_code = str(route.status_code)
         response_schema = {"type": "string"}
         if lenient_issubclass(route.content_type, JSONResponse):