mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-16 11:12:21 +03:00
Make inflection compat layer consistent with the others
Co-authored-by: T. Franzel <13507857+tfranzel@users.noreply.github.com>
This commit is contained in:
parent
4dcfc8c647
commit
492529006d
|
@ -48,12 +48,9 @@ except ImportError:
|
|||
|
||||
# inflection is optional
|
||||
try:
|
||||
from inflection import pluralize
|
||||
import inflection
|
||||
except ImportError:
|
||||
def pluralize(text):
|
||||
if not text.endswith('s'):
|
||||
text += "s"
|
||||
return text
|
||||
inflection = None
|
||||
|
||||
|
||||
# requests is optional
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.utils.encoding import force_str
|
|||
from rest_framework import (
|
||||
RemovedInDRF315Warning, exceptions, renderers, serializers
|
||||
)
|
||||
from rest_framework.compat import pluralize, uritemplate
|
||||
from rest_framework.compat import inflection, uritemplate
|
||||
from rest_framework.fields import _UnvalidatedField, empty
|
||||
from rest_framework.settings import api_settings
|
||||
|
||||
|
@ -247,7 +247,8 @@ class AutoSchema(ViewInspector):
|
|||
name = name[:-len(action)]
|
||||
|
||||
if action == 'list':
|
||||
name = pluralize(name)
|
||||
assert inflection, '`inflection` must be installed for OpenAPI schema support.'
|
||||
name = inflection.pluralize(name)
|
||||
|
||||
return name
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user