first commit

This commit is contained in:
A'zamov Samandar
2025-11-21 14:41:16 +05:00
commit 256e80cc23
161 changed files with 7052 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
SPECTACULAR_SETTINGS = {
"TITLE": "Your Project API",
"DESCRIPTION": "Your project description",
"VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False,
"CAMELIZE_NAMES": True,
"POSTPROCESSING_HOOKS": ["config.conf.spectacular.custom_postprocessing_hook"],
}
def custom_postprocessing_hook(result, generator, request, public):
"""
Customizes the API schema to wrap all responses in a standard format.
"""
for path, methods in result.get("paths", {}).items():
for method, operation in methods.items():
if "responses" in operation:
for status_code, response in operation["responses"].items():
if "content" in response and status_code in ["200", "201", "202"]:
for content_type, content in response["content"].items():
# Wrap original schema
original_schema = content.get("schema", {})
response["content"][content_type]["schema"] = {
"type": "object",
"properties": {
"status": {"type": "boolean", "example": True},
"data": original_schema,
},
"required": ["status", "data"],
}
return result