Refactor get_field_info method to include max_digits and decimal_places attributes in SimpleMetadata class by mahdirahimi1999 · Pull Request #8943 · encode/django-rest-framework (original) (raw)
Refactor get_field_info method to include max_digits and decimal_places attributes in SimpleMetadata class
This commit adds the max_digits and decimal_places attributes to the list of attributes included in the get_field_info method of the SimpleMetadata class in the Django Rest Framework. These attributes provide additional information about decimal fields, which was not previously included in the metadata. By adding these attributes to the output of the method, clients consuming the API will have more complete information about the fields in the serialized data, allowing them to make more informed decisions about how to interact with the API. This change was made in response to user feedback and is not expected to have any negative impact on existing functionality.
{
"name": "My View",
"description": "This is a view.",
"renders": ["application/json"],
"parses": ["application/json"],
"actions": {
"PUT": {
"type": "nested object",
"required": true,
"children": {
"id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "ID",
"help_text": "The ID of the object."
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"help_text": "The name of the object."
},
"price": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Price",
"help_text": "The price of the object.",
}
}
}
}
}
{
"name": "My View",
"description": "This is a view.",
"renders": ["application/json"],
"parses": ["application/json"],
"actions": {
"PUT": {
"type": "nested object",
"required": true,
"children": {
"id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "ID",
"help_text": "The ID of the object."
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"help_text": "The name of the object."
},
"price": {
"type": "decimal",
"required": true,
"read_only": false,
"label": "Price",
"help_text": "The price of the object.",
"max_digits": 6,
"decimal_places": 2
}
}
}
}
}