mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Stop ignoring variable names in paths
This commit is contained in:
parent
20c7a24c14
commit
bf1233b62b
|
@ -647,9 +647,8 @@ class SchemaGenerator(object):
|
||||||
action = self.default_mapping[method.lower()]
|
action = self.default_mapping[method.lower()]
|
||||||
|
|
||||||
named_path_components = [
|
named_path_components = [
|
||||||
component for component
|
component.strip('{}') for component
|
||||||
in subpath.strip('/').split('/')
|
in subpath.strip('/').split('/')
|
||||||
if '{' not in component
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if is_custom_action(action):
|
if is_custom_action(action):
|
||||||
|
|
|
@ -115,6 +115,7 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
action='get'
|
action='get'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
'id': {
|
||||||
'read': coreapi.Link(
|
'read': coreapi.Link(
|
||||||
url='/example/{id}/',
|
url='/example/{id}/',
|
||||||
action='get',
|
action='get',
|
||||||
|
@ -122,6 +123,7 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -155,24 +157,6 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B'))
|
coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B'))
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
'read': coreapi.Link(
|
|
||||||
url='/example/{id}/',
|
|
||||||
action='get',
|
|
||||||
fields=[
|
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
|
||||||
]
|
|
||||||
),
|
|
||||||
'custom_action': coreapi.Link(
|
|
||||||
url='/example/{id}/custom_action/',
|
|
||||||
action='post',
|
|
||||||
encoding='application/json',
|
|
||||||
description='A description of custom action.',
|
|
||||||
fields=[
|
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String()),
|
|
||||||
coreapi.Field('c', required=True, location='form', schema=coreschema.String(title='C')),
|
|
||||||
coreapi.Field('d', required=False, location='form', schema=coreschema.String(title='D')),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
'custom_list_action': coreapi.Link(
|
'custom_list_action': coreapi.Link(
|
||||||
url='/example/custom_list_action/',
|
url='/example/custom_list_action/',
|
||||||
action='get'
|
action='get'
|
||||||
|
@ -187,6 +171,14 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
action='post'
|
action='post'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
'id': {
|
||||||
|
'read': coreapi.Link(
|
||||||
|
url='/example/{id}/',
|
||||||
|
action='get',
|
||||||
|
fields=[
|
||||||
|
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||||
|
]
|
||||||
|
),
|
||||||
'update': coreapi.Link(
|
'update': coreapi.Link(
|
||||||
url='/example/{id}/',
|
url='/example/{id}/',
|
||||||
action='put',
|
action='put',
|
||||||
|
@ -213,7 +205,19 @@ class TestRouterGeneratedSchema(TestCase):
|
||||||
fields=[
|
fields=[
|
||||||
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
coreapi.Field('id', required=True, location='path', schema=coreschema.String())
|
||||||
]
|
]
|
||||||
)
|
),
|
||||||
|
'custom_action': coreapi.Link(
|
||||||
|
url='/example/{id}/custom_action/',
|
||||||
|
action='post',
|
||||||
|
encoding='application/json',
|
||||||
|
description='A description of custom action.',
|
||||||
|
fields=[
|
||||||
|
coreapi.Field('id', required=True, location='path', schema=coreschema.String()),
|
||||||
|
coreapi.Field('c', required=True, location='form', schema=coreschema.String(title='C')),
|
||||||
|
coreapi.Field('d', required=False, location='form', schema=coreschema.String(title='D')),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -293,6 +297,7 @@ class TestSchemaGenerator(TestCase):
|
||||||
action='get',
|
action='get',
|
||||||
fields=[]
|
fields=[]
|
||||||
),
|
),
|
||||||
|
'id': {
|
||||||
'read': coreapi.Link(
|
'read': coreapi.Link(
|
||||||
url='/example/{id}/',
|
url='/example/{id}/',
|
||||||
action='get',
|
action='get',
|
||||||
|
@ -311,6 +316,7 @@ class TestSchemaGenerator(TestCase):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
assert schema == expected
|
assert schema == expected
|
||||||
|
|
||||||
|
@ -346,6 +352,7 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
||||||
action='get',
|
action='get',
|
||||||
fields=[]
|
fields=[]
|
||||||
),
|
),
|
||||||
|
'id': {
|
||||||
'read': coreapi.Link(
|
'read': coreapi.Link(
|
||||||
url='/api/v1/example/{id}/',
|
url='/api/v1/example/{id}/',
|
||||||
action='get',
|
action='get',
|
||||||
|
@ -364,6 +371,7 @@ class TestSchemaGeneratorNotAtRoot(TestCase):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
assert schema == expected
|
assert schema == expected
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user