@@ -70,10 +70,10 @@ def get_resource_name(context):
7070 if not isinstance (resource_name , six .string_types ):
7171 return resource_name
7272
73- resource_name = inflection .pluralize (resource_name .lower ())
74-
7573 resource_name = format_value (resource_name )
7674
75+ resource_name = inflection .pluralize (resource_name )
76+
7777 return resource_name
7878
7979
@@ -94,17 +94,22 @@ def format_keys(obj, format_type=None):
9494 if format_type is None :
9595 format_type = getattr (settings , 'JSON_API_FORMAT_KEYS' , False )
9696
97- if format_type in ('dasherize' , 'camelize' , 'underscore' ):
97+ if format_type in ('dasherize' , 'camelize' , 'underscore' , 'capitalize' ):
9898
9999 if isinstance (obj , dict ):
100100 formatted = OrderedDict ()
101101 for key , value in obj .items ():
102102 if format_type == 'dasherize' :
103+ # inflection can't dasherize camelCase
104+ key = inflection .underscore (key )
103105 formatted [inflection .dasherize (key )] \
104106 = format_keys (value , format_type )
105107 elif format_type == 'camelize' :
106108 formatted [inflection .camelize (key , False )] \
107109 = format_keys (value , format_type )
110+ elif format_type == 'capitalize' :
111+ formatted [inflection .camelize (key )] \
112+ = format_keys (value , format_type )
108113 elif format_type == 'underscore' :
109114 formatted [inflection .underscore (key )] \
110115 = format_keys (value , format_type )
@@ -121,8 +126,12 @@ def format_value(value, format_type=None):
121126 if format_type is None :
122127 format_type = getattr (settings , 'JSON_API_FORMAT_KEYS' , False )
123128 if format_type == 'dasherize' :
129+ # inflection can't dasherize camelCase
130+ value = inflection .underscore (value )
124131 value = inflection .dasherize (value )
125132 elif format_type == 'camelize' :
133+ value = inflection .camelize (value , False )
134+ elif format_type == 'capitalize' :
126135 value = inflection .camelize (value )
127136 elif format_type == 'underscore' :
128137 value = inflection .underscore (value )
@@ -132,15 +141,10 @@ def format_value(value, format_type=None):
132141def format_relation_name (value , format_type = None ):
133142 if format_type is None :
134143 format_type = getattr (settings , 'JSON_API_FORMAT_RELATION_KEYS' , False )
135-
144+
136145 if not format_type :
137- # let's keep it the way it was
138146 return value
139147
140- # in case the value is going to be changed, make it underscored first
141- # because dasherize does not work with a camel cased string
142- value = inflection .underscore (value )
143-
144148 # format_type will never be None here so we can use format_value
145149 value = format_value (value , format_type )
146150
0 commit comments