#NEWLINE# def getdesc( root , host_url = '' ) : #NEWLINE# #INDENT# methods = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( path , funcdef ) in root . getapi ( ) : #NEWLINE# #INDENT# method = funcdef . extra_options . get ( 'method' , None ) #NEWLINE# name = '_' . join ( path ) #NEWLINE# if ( method is not None ) : #NEWLINE# #INDENT# path = path [ : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# method = 'GET' #NEWLINE# for argdef in funcdef . arguments : #NEWLINE# #INDENT# if ( types . iscomplex ( argdef . datatype ) or types . isarray ( argdef . datatype ) or types . isdict ( argdef . datatype ) ) : #NEWLINE# #INDENT# method = 'POST' #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# required_params = [ ] #NEWLINE# optional_params = [ ] #NEWLINE# for argdef in funcdef . arguments : #NEWLINE# #INDENT# if ( ( method == 'GET' ) and argdef . mandatory ) : #NEWLINE# #INDENT# required_params . append ( argdef . name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# optional_params . append ( argdef . name ) #NEWLINE# #UNINDENT# #UNINDENT# methods [ name ] = { #NEWLINE# #INDENT# 'method' : method , #NEWLINE# 'path' : '/' . join ( path ) , #NEWLINE# #UNINDENT# } #NEWLINE# if required_params : #NEWLINE# #INDENT# methods [ name ] [ 'required_params' ] = required_params #NEWLINE# #UNINDENT# if optional_params : #NEWLINE# #INDENT# methods [ name ] [ 'optional_params' ] = optional_params #NEWLINE# #UNINDENT# if funcdef . doc : #NEWLINE# #INDENT# methods [ name ] [ 'documentation' ] = funcdef . doc #NEWLINE# #UNINDENT# #UNINDENT# formats = [ ] #NEWLINE# for p in root . protocols : #NEWLINE# #INDENT# if ( p . name == 'restxml' ) : #NEWLINE# #INDENT# formats . append ( 'xml' ) #NEWLINE# #UNINDENT# if ( p . name == 'restjson' ) : #NEWLINE# #INDENT# formats . append ( 'json' ) #NEWLINE# #UNINDENT# #UNINDENT# api = { #NEWLINE# #INDENT# 'base_url' : ( host_url + root . _webpath ) , #NEWLINE# 'version' : '0.1' , #NEWLINE# 'name' : getattr ( root , 'name' , 'name' ) , #NEWLINE# 'authority' : '' , #NEWLINE# 'formats' : [ 'json' , 'xml' ] , #NEWLINE# 'methods' : methods , #NEWLINE# #UNINDENT# } #NEWLINE# return json . dumps ( api , indent = 4 )