mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-16 19:22:24 +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
|
# inflection is optional
|
||||||
try:
|
try:
|
||||||
from inflection import pluralize
|
import inflection
|
||||||
except ImportError:
|
except ImportError:
|
||||||
def pluralize(text):
|
inflection = None
|
||||||
if not text.endswith('s'):
|
|
||||||
text += "s"
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
# requests is optional
|
# requests is optional
|
||||||
|
|
|
@ -14,7 +14,7 @@ from django.utils.encoding import force_str
|
||||||
from rest_framework import (
|
from rest_framework import (
|
||||||
RemovedInDRF315Warning, exceptions, renderers, serializers
|
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.fields import _UnvalidatedField, empty
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
|
@ -247,7 +247,8 @@ class AutoSchema(ViewInspector):
|
||||||
name = name[:-len(action)]
|
name = name[:-len(action)]
|
||||||
|
|
||||||
if action == 'list':
|
if action == 'list':
|
||||||
name = pluralize(name)
|
assert inflection, '`inflection` must be installed for OpenAPI schema support.'
|
||||||
|
name = inflection.pluralize(name)
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user