コード例 #1
0
 def test_extract_path_with_multiple_parameters(self):
     path = "/test/<parameter>/<int:other>/"
     self.assertEqual(
         extract_path_params(path),
         {
             "parameter": {"name": "parameter", "type": "string", "in": "path", "required": True},
             "other": {"name": "other", "type": "integer", "in": "path", "required": True},
         },
     )
コード例 #2
0
 def test_single_float_parameter(self):
     path = '/test/<float:parameter>'
     self.assertEqual(extract_path_params(path), {
         'parameter': {
             'name': 'parameter',
             'type': 'number',
             'in': 'path',
             'required': True
         }
     })
コード例 #3
0
 def test_extract_single_simple_parameter(self):
     path = '/test/<parameter>'
     self.assertEqual(extract_path_params(path), {
         'parameter': {
             'name': 'parameter',
             'type': 'string',
             'in': 'path',
             'required': True
         }
     })
コード例 #4
0
 def test_extract_parameter_with_arguments(self):
     path = '/test/<string(length=2):parameter>'
     assert extract_path_params(path) == {
         'parameter': {
             'name': 'parameter',
             'type': 'string',
             'in': 'path',
             'required': True
         }
     }
コード例 #5
0
 def test_single_int_parameter(self):
     path = '/test/<int:parameter>'
     assert extract_path_params(path) == {
         'parameter': {
             'name': 'parameter',
             'type': 'integer',
             'in': 'path',
             'required': True
         }
     }
コード例 #6
0
 def test_extract_path_with_multiple_parameters(self):
     path = '/test/<parameter>/<int:other>/'
     self.assertEqual(extract_path_params(path), {
         'parameter': {
             'name': 'parameter',
             'type': 'string',
             'in': 'path',
             'required': True
         },
         'other': {
             'name': 'other',
             'type': 'integer',
             'in': 'path',
             'required': True
         }
     })
コード例 #7
0
 def extract_resource_doc(self, resource, url):
     doc = getattr(resource, '__apidoc__', {})
     if doc is False:
         return False
     doc['name'] = resource.__name__
     doc['params'] = extract_path_params(url)
     for action in self.get_actions(resource):
         action_doc = doc.get(action, {})
         action_impl = getattr(resource, action)
         if hasattr(action_impl, 'im_func'):
             action_impl = action_impl.im_func
         elif hasattr(action_impl, '__func__'):
             action_impl = action_impl.__func__
         action_doc = merge(action_doc, getattr(action_impl, '__apidoc__', {}))
         if action_doc is not False:
             action_doc['docstring'] = getattr(action_impl, '__doc__')
             action_doc['params'] = self.merge_params({}, action_doc)
         doc[action] = action_doc
     return doc
コード例 #8
0
 def test_extract_static_path(self):
     path = '/test'
     self.assertEqual(extract_path_params(path), {})
コード例 #9
0
 def test_extract_static_path(self):
     path = '/test'
     self.assertEqual(extract_path_params(path), {})
コード例 #10
0
 def test_extract_static_path(self):
     path = '/test'
     assert extract_path_params(path) == {}
コード例 #11
0
 def test_single_float_parameter(self):
     path = "/test/<float:parameter>"
     self.assertEqual(
         extract_path_params(path),
         {"parameter": {"name": "parameter", "type": "number", "in": "path", "required": True}},
     )
コード例 #12
0
 def test_extract_single_simple_parameter(self):
     path = "/test/<parameter>"
     self.assertEqual(
         extract_path_params(path),
         {"parameter": {"name": "parameter", "type": "string", "in": "path", "required": True}},
     )