diff --git a/django_api_decorator/openapi.py b/django_api_decorator/openapi.py index 2c5bd86..887a64b 100644 --- a/django_api_decorator/openapi.py +++ b/django_api_decorator/openapi.py @@ -138,6 +138,8 @@ def to_ref_if_object(schema: dict[str, Any]) -> dict[str, Any]: ref_template=schema_ref ) schema = to_ref_if_object(schema) + if field.default != PydanticUndefined: + schema["default"] = field.default param = { "name": field.alias or name, @@ -145,8 +147,6 @@ def to_ref_if_object(schema: dict[str, Any]) -> dict[str, Any]: "required": field.is_required(), "schema": schema, } - if field.default != PydanticUndefined: - param["default"] = field.default parameters.append(param) # Assuming standard django folder structure with [project name]/[app name]/....