@ -46,8 +46,8 @@ HTTP_APIS = {
SWAGGER_DEFINITIONS = {
SWAGGER_DEFINITIONS = {
os . path . join ( matrix_doc_dir , " api/application-service/definitions " ) : " as " ,
os . path . join ( matrix_doc_dir , " api/application-service/definitions " ) : " as " ,
os . path . join ( matrix_doc_dir , " api/client-server/definitions " ) : " cs " ,
os . path . join ( matrix_doc_dir , " api/client-server/definitions " ) : " cs " ,
#os.path.join(matrix_doc_dir, "api/identity/definitions"): "is" ,
os . path . join ( matrix_doc_dir , " api/identity/definitions " ) : " is " ,
#os.path.join(matrix_doc_dir, "api/push-gateway/definitions"): "push" ,
os . path . join ( matrix_doc_dir , " api/push-gateway/definitions " ) : " push " ,
os . path . join ( matrix_doc_dir , " api/server-server/definitions " ) : " ss " ,
os . path . join ( matrix_doc_dir , " api/server-server/definitions " ) : " ss " ,
}
}
EVENT_EXAMPLES = os . path . join ( matrix_doc_dir , " event-schemas/examples " )
EVENT_EXAMPLES = os . path . join ( matrix_doc_dir , " event-schemas/examples " )
@ -665,14 +665,27 @@ class MatrixUnits(Units):
def load_swagger_definitions ( self ) :
def load_swagger_definitions ( self ) :
defs = { }
defs = { }
for path , prefix in SWAGGER_DEFINITIONS . items ( ) :
for path , prefix in SWAGGER_DEFINITIONS . items ( ) :
self . _load_swagger_definitions_in_dir ( defs , path , prefix )
return defs
def _load_swagger_definitions_in_dir ( self , defs , path , prefix , recurse = True ) :
if not os . path . exists ( path ) :
return defs
for filename in os . listdir ( path ) :
for filename in os . listdir ( path ) :
filepath = os . path . join ( path , filename )
if os . path . isdir ( filepath ) and recurse :
safe_name = re . sub ( r " [^a-zA-Z0-9_] " , " _ " , filename )
dir_prefix = " _ " . join ( [ prefix , safe_name ] )
# We don't recurse because we have to stop at some point
self . _load_swagger_definitions_in_dir (
defs , filepath , dir_prefix , recurse = False )
if not filename . endswith ( " .yaml " ) :
if not filename . endswith ( " .yaml " ) :
continue
continue
filepath = os . path . join ( path , filename )
filepath = os . path . join ( path , filename )
logger . info ( " Reading swagger definition: %s " % filepath )
logger . info ( " Reading swagger definition: %s " % filepath )
with open ( filepath , " r " ) as f :
with open ( filepath , " r " ) as f :
# strip .yaml
# strip .yaml
group_name = filename [ : - 5 ] . replace ( " - " , " _ " )
group_name = re . sub ( r " [^a-zA-Z0-9_] " , " _ " , filename [ : - 5 ] )
group_name = " %s _ %s " % ( prefix , group_name )
group_name = " %s _ %s " % ( prefix , group_name )
definition = yaml . load ( f . read ( ) , OrderedLoader )
definition = yaml . load ( f . read ( ) , OrderedLoader )
definition = resolve_references ( filepath , definition )
definition = resolve_references ( filepath , definition )
@ -692,7 +705,6 @@ class MatrixUnits(Units):
}
}
return defs
return defs
def load_common_event_fields ( self ) :
def load_common_event_fields ( self ) :
""" Parse the core event schema files
""" Parse the core event schema files