Skip to content

Commit 50b3c05

Browse files
author
Marcin Lubimow
committed
Fix for key collision
1 parent f1f657d commit 50b3c05

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rest_framework/schemas/generators.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ def __init__(self):
7171
super(LinkNode, self).__init__()
7272

7373
def get_next_key(self, method):
74-
current_val = self.methods_counter[method]
75-
self.methods_counter[method] += 1
76-
return '{}_{}'.format(method, current_val)
74+
while True:
75+
current_val = self.methods_counter[method]
76+
self.methods_counter[method] += 1
77+
78+
key = '{}_{}'.format(method, current_val)
79+
if key not in self:
80+
return key
7781

7882

7983
def insert_into(target, keys, value):

0 commit comments

Comments
 (0)