PHPXMLRPC-EXTRAS

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
todo

use some AJAX magic to implement jsonrpc calls to test/debug methods without feeding to user the raw json

todo

add some i18n support

todo

add a sane way to have a set of http headers to be sent along with every type of generated documentation (eg. content-type)

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_doctype

public string $default_doctype = 'html'

default format for generated documentation: either wsdl or html

$_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' => ' "", ', )

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
throws
Exception
Return values
Response|string

setTemplate()

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
string

handleNonRPCRequest()

protected handleNonRPCRequest(mixed $docType, mixed $returnPayload) : mixed
Parameters
$docType : mixed
$returnPayload : mixed

        
On this page

Search results