Update schema.py

This commit is contained in:
Abhimanyu Saharan 2023-04-12 12:45:38 +05:30 committed by GitHub
parent 3808a2735f
commit 5437f57ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -245,12 +245,9 @@ class NetBoxAutoSchema(AutoSchema):
""" """
Generate a docstring for the method. It also takes into account whether the method is for list or detail. Generate a docstring for the method. It also takes into account whether the method is for list or detail.
""" """
# Determine if the method is for list or detail.
is_list = not '{id}' in self.path
model_name = self.view.queryset.model._meta.verbose_name model_name = self.view.queryset.model._meta.verbose_name
if is_list: # Determine if the method is for list or detail.
return f"{self.method.capitalize()} a list of {model_name} objects." if '{id}' in self.path:
return f"{self.method.capitalize()} a {model_name} object." return f"{self.method.capitalize()} a {model_name} object."
return f"{self.method.capitalize()} a list of {model_name} objects."