From 44a17acec3a75ce856ea0121be94e134d88b3e14 Mon Sep 17 00:00:00 2001 From: Nikolay Kiryanov Date: Sat, 25 Jul 2026 18:41:18 +0300 Subject: [PATCH] Generate OpenAPI 3.1 with split request schemas Request and response get separate components. A single schema for both directions puts read-only fields into request types, and forces a file field to be a URL and an upload at the same time. --- {{ cookiecutter.name }}/src/app/conf/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{ cookiecutter.name }}/src/app/conf/api.py b/{{ cookiecutter.name }}/src/app/conf/api.py index 01ecf27d..7ab0ca58 100644 --- a/{{ cookiecutter.name }}/src/app/conf/api.py +++ b/{{ cookiecutter.name }}/src/app/conf/api.py @@ -37,6 +37,8 @@ SPECTACULAR_SETTINGS = { "TITLE": "Our fancy API", "DESCRIPTION": "So great, needs no docs", + "OAS_VERSION": "3.1.0", + "COMPONENT_SPLIT_REQUEST": True, # request and response schemas rarely match: read-only fields, write-only fields, file uploads "SWAGGER_UI_DIST": "SIDECAR", "SWAGGER_UI_FAVICON_HREF": "SIDECAR", "REDOC_DIST": "SIDECAR",