Why does Swagger show "422 Validation Error" under the responses section of my docs?

Viewed 816

I'm building a REST API with Python's fastapi. One benefit of fastapi is that it automatically generates API docs using Swagger.

Here I've define a dummy delete() path operation.

from fastapi import FastAPI, status

app = FastAPI()

@app.delete('/blog/{id}', status_code=status.HTTP_204_NO_CONTENT)
def delete_blog(id: int):
    return "test"

When I visit the auto-generated swagger docs (http://127.0.0.1:8000/docs), my delete endpoint shows 422 Validation Error under Responses.

enter image description here

Where does this come from? Why don't see 422 Validation error when I create a get() path operation? And why don't I see other possible Responses like 500?

0 Answers
Related