Operation Class Reference

Inheritance diagram for Operation:

Inheritance graph
[legend]
Collaboration diagram for Operation:

Collaboration graph
[legend]

Public Member Functions

def __init__
def load

Data Fields

 body_parameter
 error_responses
 has_body_parameter
 has_error_responses
 has_header_parameters
 has_parameters
 has_path_parameters
 has_query_parameters
 header_parameters
 http_method
 is_req
 is_websocket
 nickname
 notes
 parameters
 path_parameters
 query_parameters
 response_class
 summary
 websocket_protocol

Static Public Attributes

list required_fields = ['httpMethod', 'nickname', 'responseClass', 'summary']

Detailed Description

Model of an operation on an API

See https://github.com/wordnik/swagger-core/wiki/API-Declaration#apis

Definition at line 353 of file swagger_model.py.


Member Function Documentation

def __init__ (   self  ) 

Definition at line 361 of file swagger_model.py.

00361                       :
00362         self.http_method = None
00363         self.nickname = None
00364         self.response_class = None
00365         self.parameters = []
00366         self.summary = None
00367         self.notes = None
00368         self.error_responses = []
00369 
    def load(self, op_json, processor, context):

def load (   self,
  op_json,
  processor,
  context 
)

Definition at line 370 of file swagger_model.py.

00370                                                :
00371         context = context.next_stack(op_json, 'nickname')
00372         validate_required_fields(op_json, self.required_fields, context)
00373         self.http_method = op_json.get('httpMethod')
00374         self.nickname = op_json.get('nickname')
00375         response_class = op_json.get('responseClass')
00376         self.response_class = response_class and SwaggerType().load(
00377             response_class, processor, context)
00378 
00379         # Specifying WebSocket URL's is our own extension
00380         self.is_websocket = op_json.get('upgrade') == 'websocket'
00381         self.is_req = not self.is_websocket
00382 
00383         if self.is_websocket:
00384             self.websocket_protocol = op_json.get('websocketProtocol')
00385             if self.http_method != 'GET':
00386                 raise SwaggerError(
00387                     "upgrade: websocket is only valid on GET operations",
00388                     context)
00389 
00390         params_json = op_json.get('parameters') or []
00391         self.parameters = [
00392             Parameter().load(j, processor, context) for j in params_json]
00393         self.query_parameters = [
00394             p for p in self.parameters if p.is_type('query')]
00395         self.has_query_parameters = self.query_parameters and True
00396         self.path_parameters = [
00397             p for p in self.parameters if p.is_type('path')]
00398         self.has_path_parameters = self.path_parameters and True
00399         self.header_parameters = [
00400             p for p in self.parameters if p.is_type('header')]
00401         self.has_header_parameters = self.header_parameters and True
00402         self.has_parameters = self.has_query_parameters or \
00403             self.has_path_parameters or self.has_header_parameters
00404 
00405         # Body param is different, since there's at most one
00406         self.body_parameter = [
00407             p for p in self.parameters if p.is_type('body')]
00408         if len(self.body_parameter) > 1:
00409             raise SwaggerError("Cannot have more than one body param", context)
00410         self.body_parameter = self.body_parameter and self.body_parameter[0]
00411         self.has_body_parameter = self.body_parameter and True
00412 
00413         self.summary = op_json.get('summary')
00414         self.notes = op_json.get('notes')
00415         err_json = op_json.get('errorResponses') or []
00416         self.error_responses = [
00417             ErrorResponse().load(j, processor, context) for j in err_json]
00418         self.has_error_responses = self.error_responses != []
00419         processor.process_operation(self, context)
00420         return self
00421 
00422 
class Api(Stringify):


Field Documentation

Definition at line 406 of file swagger_model.py.

Definition at line 368 of file swagger_model.py.

Definition at line 411 of file swagger_model.py.

Definition at line 418 of file swagger_model.py.

Definition at line 401 of file swagger_model.py.

Definition at line 402 of file swagger_model.py.

Definition at line 398 of file swagger_model.py.

Definition at line 395 of file swagger_model.py.

Definition at line 399 of file swagger_model.py.

Definition at line 362 of file swagger_model.py.

Definition at line 381 of file swagger_model.py.

Definition at line 380 of file swagger_model.py.

Definition at line 363 of file swagger_model.py.

Definition at line 367 of file swagger_model.py.

Definition at line 365 of file swagger_model.py.

Definition at line 396 of file swagger_model.py.

Definition at line 393 of file swagger_model.py.

list required_fields = ['httpMethod', 'nickname', 'responseClass', 'summary'] [static]

Definition at line 359 of file swagger_model.py.

Definition at line 364 of file swagger_model.py.

Definition at line 366 of file swagger_model.py.

Definition at line 384 of file swagger_model.py.


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

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