Esempio n. 1
0
 def get_header_parameters(self):
     if self.version_name:
         return [build_swagger_parameter(
             preset  = "http_accept", 
             default = self.version_name,
         )]
     return []
Esempio n. 2
0
 def get_form_parameters(self, method):
     def get_typename(widget): 
         if getattr(widget, 'input_type', '') == 'number':
             return 'number', None
         elif getattr(widget, 'allow_multiple_selected', False):
             return 'array', {'type': 'string'}
         return 'string', None
         
     parameters = []
     if hasattr(method, 'form_class'):
         for each in method.form_class():
             maximum = minimum = pattern = None
             for validator in each.field.validators:
                 if validator.code.startswith('max_'):
                     maximum = validator.limit_value
                 elif validator.code.startswith('min_'):
                     minimum = validator.limit_value
                 if hasattr(validator, 'regex'):
                     pattern = validator.regex
             typename, items = get_typename(each.field.widget)
             parameters.append( 
                 build_swagger_parameter(
                     location    = 'form', 
                     name        = each.name, 
                     typename    = typename,
                     description = each.field.help_text, 
                     required    = each.field.required,
                     items       = items,
                     maximum     = maximum,
                     minimum     = minimum,
                     pattern     = pattern,
                 )
             )
     return parameters
Esempio n. 3
0
File: base.py Progetto: laginha/yard
 def get_documentation(self):
     def get_default():
         if self.default:
             if callable(self.default):
                 if not inspect.getargspec(self.default).args:
                     return self.default()
             return self.default
         
     return build_swagger_parameter(
         location = 'query', name = self.name, typename = self.typename,
         description = self.description, required = self.required,
         default = get_default()
     )
Esempio n. 4
0
 def get_path_parameter(self):
     return build_swagger_parameter(preset='path')