parameters: (spec_json, origin='unknown')
docstring: :param spec_json: Dict representation of the json API spec
      :param origin: filename or url of the spec - only use for error messages
      :return: module responsible for validation based on Swagger version in the
          spec
docstring_summary: :param spec_json: Dict representation of the json API spec
      :param origin: filename or url of the spec - only use for error messages
      :return: module responsible for validation based on Swagger version in the
          spec
docstring_tokens: : param spec_json : Dict representation of the json API spec : param origin : filename or url of the spec - only use for error messages : return : module responsible for validation based on Swagger version in the spec
function: def get_validator(spec_json, origin='unknown'):
      """
      :param spec_json: Dict representation of the json API spec
      :param origin: filename or url of the spec - only use for error messages
      :return: module responsible for validation based on Swagger version in the
          spec
      """
      swagger12_version = spec_json.get('swaggerVersion')
      swagger20_version = spec_json.get('swagger')
  
      if swagger12_version and swagger20_version:
          raise SwaggerValidationError(
              "You've got conflicting keys for the Swagger version in your spec. "
              "Expected `swaggerVersion` or `swagger`, but not both.")
      elif swagger12_version and swagger12_version == '1.2':
          # we don't care about versions prior to 1.2
          return validator12
      elif swagger20_version and swagger20_version == '2.0':
          return validator20
      elif swagger12_version is None and swagger20_version is None:
          raise SwaggerValidationError(
              "Swagger spec {} missing version. Expected "
              "`swaggerVersion` or `swagger`".format(origin))
      else:
          raise SwaggerValidationError(
              'Swagger version {} not supported.'.format(
                  swagger12_version or swagger20_version))
function_tokens: def get_validator ( spec_json , origin = 'unknown' ) : swagger12_version = spec_json . get ( 'swaggerVersion' ) swagger20_version = spec_json . get ( 'swagger' ) if swagger12_version and swagger20_version : raise SwaggerValidationError ( "You've got conflicting keys for the Swagger version in your spec. " "Expected `swaggerVersion` or `swagger`, but not both." ) elif swagger12_version and swagger12_version == '1.2' : # we don't care about versions prior to 1.2 return validator12 elif swagger20_version and swagger20_version == '2.0' : return validator20 elif swagger12_version is None and swagger20_version is None : raise SwaggerValidationError ( "Swagger spec {} missing version. Expected " "`swaggerVersion` or `swagger`" . format ( origin ) ) else : raise SwaggerValidationError ( 'Swagger version {} not supported.' . format ( swagger12_version or swagger20_version ) )