Asterisk - The Open Source Telephony Project  GIT-master-a1fa8df
Public Member Functions | Data Fields | Static Public Attributes
ResourceListing Class Reference

Inherits Stringify.

Public Member Functions

def __init__ (self)
def load (self, resources_json, processor, context)
def load_file (self, resource_file, processor)
- Public Member Functions inherited from Stringify
def __repr__ (self)

Data Fields


Static Public Attributes

list required_fields = ['apiVersion', 'basePath', 'apis']

Detailed Description

Model of Swagger's resources.json file.

Definition at line 708 of file

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Definition at line 714 of file

714  def __init__(self):
715  self.swagger_version = None
716  self.api_version = None
717  self.base_path = None
718  self.apis = None

Member Function Documentation

◆ load()

def load (   self,

Definition at line 735 of file

References ApiDeclaration.api_version, ResourceListing.api_version, ApiDeclaration.apis, ResourceListing.apis, ApiDeclaration.base_path, ResourceListing.base_path, Parameter.required_fields, ErrorResponse.required_fields, Operation.required_fields, Api.required_fields, Property.required_fields, Model.required_fields, ApiDeclaration.required_fields, ResourceApi.required_fields, ResourceListing.required_fields, ParsingContext.swagger_version, ApiDeclaration.swagger_version, ResourceListing.swagger_version, and swagger_model.validate_required_fields().

Referenced by ResourceListing.load_file().

735  def load(self, resources_json, processor, context):
736  # If the version doesn't match, all bets are off.
737  self.swagger_version = resources_json.get('swaggerVersion')
738  if not self.swagger_version in SWAGGER_VERSIONS:
739  raise SwaggerError(
740  "Unsupported Swagger version %s" % self.swagger_version, context)
742  validate_required_fields(resources_json, self.required_fields, context)
743  self.api_version = resources_json['apiVersion']
744  self.base_path = resources_json['basePath']
745  apis_json = resources_json['apis']
746  self.apis = [
747  ResourceApi().load(j, processor, context) for j in apis_json]
748  processor.process_resource_listing(self, context)
749  return self
def validate_required_fields(json, required_fields, context)

◆ load_file()

def load_file (   self,

Definition at line 720 of file

References ApiDeclaration.__load_file(), ResourceListing.__load_file(), ast_speech_engine.load, Parameter.load(), ast_sorcery_wizard.load, ErrorResponse.load(), SwaggerType.load(), ast_module_info.load, Operation.load(), Api.load(), Property.load(), Model.load(), ApiDeclaration.load(), ResourceApi.load(), and ResourceListing.load().

720  def load_file(self, resource_file, processor):
721  context = ParsingContext(None, [resource_file])
722  try:
723  return self.__load_file(resource_file, processor, context)
724  except SwaggerError:
725  raise
726  except Exception as e:
727  print("Error: ", traceback.format_exc(), file=sys.stderr)
728  raise SwaggerError(
729  "Error loading %s" % resource_file, context, e)
static int load_file(const char *filename, char **ret)
Read a TEXT file into a string and return the length.

Field Documentation

◆ api_version


Definition at line 716 of file

Referenced by ResourceListing.load().

◆ apis


Definition at line 718 of file

Referenced by ResourceListing.load().

◆ base_path


Definition at line 717 of file

Referenced by ResourceListing.load().

◆ required_fields

list required_fields = ['apiVersion', 'basePath', 'apis']

Definition at line 712 of file

Referenced by ResourceListing.load().

◆ swagger_version


Definition at line 715 of file

Referenced by ResourceListing.load().

The documentation for this class was generated from the following file: