swagger_model Namespace Reference


Data Structures

class  AllowableList
class  AllowableRange
class  Api
class  ApiDeclaration
class  ErrorResponse
class  Model
class  Operation
class  Parameter
class  ParsingContext
class  Property
class  ResourceApi
class  ResourceListing
class  Stringify
class  SwaggerError
class  SwaggerPostProcessor
class  SwaggerType

Functions

def compare_versions
def get_list_parameter_type
def load_allowable_values
def validate_required_fields

Variables

list SWAGGER_PRIMITIVES
list SWAGGER_VERSIONS = ["1.1", "1.2"]


Function Documentation

def swagger_model::compare_versions (   lhs,
  rhs 
)

Performs a lexicographical comparison between two version numbers.

This properly handles simple major.minor.whatever.sure.why.not version
numbers, but fails miserably if there's any letters in there.

For reference:
  1.0 == 1.0
  1.0 < 1.0.1
  1.2 < 1.10

@param lhs Left hand side of the comparison
@param rhs Right hand side of the comparison
@return  < 0 if lhs  < rhs
@return == 0 if lhs == rhs
@return  > 0 if lhs  > rhs

Definition at line 59 of file swagger_model.py.

00059                               :
00060     '''Performs a lexicographical comparison between two version numbers.
00061 
00062     This properly handles simple major.minor.whatever.sure.why.not version
00063     numbers, but fails miserably if there's any letters in there.
00064 
00065     For reference:
00066       1.0 == 1.0
00067       1.0 < 1.0.1
00068       1.2 < 1.10
00069 
00070     @param lhs Left hand side of the comparison
00071     @param rhs Right hand side of the comparison
00072     @return  < 0 if lhs  < rhs
00073     @return == 0 if lhs == rhs
00074     @return  > 0 if lhs  > rhs
00075     '''
00076     lhs = [int(v) for v in lhs.split('.')]
00077     rhs = [int(v) for v in rhs.split('.')]
00078     return cmp(lhs, rhs)
00079 
00080 
class ParsingContext(object):

def swagger_model::get_list_parameter_type (   type_string  ) 

Returns the type parameter if the given type_string is List[].

@param type_string: Type string to parse
@returns Type parameter of the list, or None if not a List.

Definition at line 450 of file swagger_model.py.

00450                                         :
00451     """Returns the type parameter if the given type_string is List[].
00452 
00453     @param type_string: Type string to parse
00454     @returns Type parameter of the list, or None if not a List.
00455     """
00456     list_match = re.match('^List\[(.*)\]$', type_string)
00457     return list_match and list_match.group(1)
00458 
00459 
class Property(Stringify):

def swagger_model::load_allowable_values (   json,
  context 
)

Parse a JSON allowableValues object.

This returns None, AllowableList or AllowableRange, depending on the
valueType in the JSON. If the valueType is not recognized, a SwaggerError
is raised.

Definition at line 239 of file swagger_model.py.

00239                                         :
00240     """Parse a JSON allowableValues object.
00241 
00242     This returns None, AllowableList or AllowableRange, depending on the
00243     valueType in the JSON. If the valueType is not recognized, a SwaggerError
00244     is raised.
00245     """
00246     if not json:
00247         return None
00248 
00249     if not 'valueType' in json:
00250         raise SwaggerError("Missing valueType field", context)
00251 
00252     value_type = json['valueType']
00253 
00254     if value_type == 'RANGE':
00255         if not 'min' in json and not 'max' in json:
00256             raise SwaggerError("Missing fields min/max", context)
00257         return AllowableRange(json.get('min'), json.get('max'))
00258     if value_type == 'LIST':
00259         if not 'values' in json:
00260             raise SwaggerError("Missing field values", context)
00261         return AllowableList(json['values'])
00262     raise SwaggerError("Unkown valueType %s" % value_type, context)
00263 
00264 
class Parameter(Stringify):

def swagger_model::validate_required_fields (   json,
  required_fields,
  context 
)

Checks a JSON object for a set of required fields.

If any required field is missing, a SwaggerError is raised.

@param json: JSON object to check.
@param required_fields: List of required fields.
@param context: Current context in the API.

Definition at line 749 of file swagger_model.py.

00749                                                             :
00750     """Checks a JSON object for a set of required fields.
00751 
00752     If any required field is missing, a SwaggerError is raised.
00753 
00754     @param json: JSON object to check.
00755     @param required_fields: List of required fields.
00756     @param context: Current context in the API.
00757     """
00758     missing_fields = [f for f in required_fields if not f in json]
00759 
00760     if missing_fields:
00761         raise SwaggerError(
00762             "Missing fields: %s" % ', '.join(missing_fields), context)
            "Missing fields: %s" % ', '.join(missing_fields), context)


Variable Documentation

Definition at line 39 of file swagger_model.py.

list SWAGGER_VERSIONS = ["1.1", "1.2"]

Definition at line 37 of file swagger_model.py.


Generated on Thu Apr 16 06:41:38 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6