tezvyn:

How do you document multiple response schemas in OpenAPI?

Source: fastapi.tiangolo.comintermediate

This tests FastAPI OpenAPI schema generation for error responses. A strong answer covers the decorator responses dict mapping status codes to Pydantic models and descriptions, plus manually returning JSONResponse with that code.

This tests whether you understand how FastAPI generates OpenAPI schemas for endpoints returning multiple status codes. A strong answer explains the responses parameter on the path operation decorator, which accepts a dictionary mapping status codes to dictionaries with model, description, and metadata. It also notes that while this populates the docs, you must manually return a JSONResponse with the correct status code at runtime. A red flag is believing that response_model alone can automatically document and return non-200 codes.

Read the original → fastapi.tiangolo.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

How do you document multiple response schemas in OpenAPI? · Tezvyn