mirror of
https://github.com/langgenius/dify.git
synced 2026-07-15 01:17:04 +08:00
Introduce two decorators in controllers/openapi/_contract.py that each own one slice of the HTTP contract from a single Pydantic model reference: - @accepts(query=, body=): validate the request, inject the validated model as a typed kwarg, and emit the Swagger param/body schema. Validation errors map to 422 with ValidationError.json() (one shape). - @returns(status, model): emit the response schema and serialize the handler's returned model via model_dump(mode="json"); non-model returns pass through. Both sit below @auth_router.guard so auth precedes validation and the unit-test __wrapped__ seam keeps unwrapping exactly the guard layer.