Patch 422 responses¶
patch_422_responses is the schema patch on its own, for a schema you build with fastapi.openapi.utils.get_openapi() outside app.openapi:
public_schema = get_openapi(
title="Inventory API", version="2.1.0", routes=app.routes
)
patch_422_responses(public_schema, "400")
public_schema documents the validation error of POST /items at 400, without the 422. The function changes the schema it receives, and returns it too. The app itself is untouched: its /openapi.json still documents 422, and a request that fails validation still gets 422, unless you also call override_validation_error.
It takes merge_target_response, with the same meaning as in override_validation_error. It's meant for the schemas get_openapi() produces; on documents written by hand or by other tools, the result is best effort.