SelfDocumentingJsonRpcServer
extends Server
in package
uses
SelfDocumentingServerTrait
Extends the base jsonrpc server with the capability to generate documentation about the exposed jsonrpc methods.
It will take advantage of a new member in the dispatch map: signature_docs it is expected to be an array with the same number of members as signature, but containing a short description for every parameter.
Tags
Table of Contents
Properties
- $default_doclang : mixed
- $default_doctype : string
- $editorpath : string|null
- $execute_on_form_submit : bool
- $supported_doctypes : array<string|int, string>
- $supported_langs : array<string|int, string>
- $_templates : mixed
- $documentationGenerator : mixed
- $templates : array<string|int, string>
Methods
- service() : Response|string
- Override service method: in case of GET requests show docs about implemented methods; in case of POST received by a form, we use the methodCall input value as if it had been sent with a tex/xml mimetype
- setTemplate() : void
- generateDocs() : string
- getTemplates() : mixed
- handleNonRPCRequest() : mixed
Properties
$default_doclang
public
mixed
$default_doclang
= 'en'
$default_doctype
public
string
$default_doctype
= 'html'
default format for generated documentation: either wsdl or html
$editorpath
public
string|null
$editorpath
= ''
relative path to the visual xml-rpc editing dialog
$execute_on_form_submit
public
bool
$execute_on_form_submit
= true
$supported_doctypes
public
array<string|int, string>
$supported_doctypes
= array('html', 'wsdl')
$supported_langs
public
array<string|int, string>
$supported_langs
= array('en')
$_templates
protected
static mixed
$_templates
= array(
/// @todo the trailing comma in `{$params}` is not valid in json
'methodfooter' => '
<h2>Test method call</h2>
<p>Complete by hand the form below inserting the needed parameters to call this method.<br/>
<form action="" method="post"><p>
<textarea id="methodCall" name="methodCall" rows="5" cols="80">{
"jsonrpc": "2.0",
"id": 1,
"method": "{$method}"
"params": [
{$params}]
}
</textarea><br/>
{$extras}
<input type="submit" value="Test"/>
</p></form>',
'formparam' => ' "",
',
)
$documentationGenerator
protected
mixed
$documentationGenerator
$templates
protected
array<string|int, string>
$templates
= array()
Methods
service()
Override service method: in case of GET requests show docs about implemented methods; in case of POST received by a form, we use the methodCall input value as if it had been sent with a tex/xml mimetype
public
service([string $data = null ][, bool $returnPayload = false ][, string $docType = '' ]) : Response|string
Parameters
- $data : string = null
-
request data to be parsed, null by default
- $returnPayload : bool = false
-
when true the payload will be returned but not echoed to screen
- $docType : string = ''
-
type of documentation to generate: html, wsdl, etc... If empty, use class default
Tags
Return values
Response|stringsetTemplate()
public
setTemplate(string $name, string $contents) : void
Parameters
- $name : string
- $contents : string
generateDocs()
protected
generateDocs([string $doctype = 'html' ][, string $lang = 'en' ][, string $editorPath = '' ][, bool $displayExecutionForm = true ]) : string
Parameters
- $doctype : string = 'html'
- $lang : string = 'en'
- $editorPath : string = ''
- $displayExecutionForm : bool = true
Return values
stringgetTemplates()
protected
getTemplates() : mixed
handleNonRPCRequest()
protected
handleNonRPCRequest(mixed $docType, mixed $returnPayload) : mixed
Parameters
- $docType : mixed
- $returnPayload : mixed