The optional library module xqrs-functions enables your Application to export all of the XQuery functions XQRS is managing along with their RESTXQ Annotations.
Another way of putting this is an Export of all of the RESTful End Points XQRS is managing. You may find this useful if you're trying to build a client which automatically knows what services are available and exactly how to call them. For example creating Unit Test Stubs for hundreds of endpoints in your favourite language and Unit test framework.
If you're using the XQRS Gradle Plugin then
this module is already installed and ready to go under the
ml-modules/root/xqrs/optional-libraries
directory.
If you're not using Gradle, download the xqrs-functions.xq
module and add an import statement to it in your
xqrs.xqy file, e.g.
import module namespace xqrs-functions =
"http://xmllondon.com/xquery/xqrs-functions" at
"optional-libraries/xqrs-functions.xq";
This provides you with 1 RESTful service
URI | Description |
---|---|
/xqrs-functions | List all the Functions/Paths managed and known by XQRS |
There is a helpful RelaxNG Schema which describes the XML structure of what will be output from this service.
The following snippet of XML code is a sample of what is produced from running the service
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://xmllondon.com/schema/xqrs-functions-1.0.rnc"
schematypens="http://xmllondon.com/xquery/xqrs-functions"?>
<functions base-url="http://prod.myserver.com:8092">
<function namespace="http://factory/xq" local-name="put-wheel" arity="2">
<path uri="/factory/wheel/{$wheel-id}">
<segment>factory</segment>
<segment>wheel</segment>
<variable-segment type="xs:string" maps-to-variable="wheel-id"/>
</path>
<method name="PUT" maps-to-variable="request-body">
<type>document-node()</type>
</method>
<consumes>text/xml</consumes>
</function>
<function namespace="http://factory/xq" local-name="get-wheel" arity="1">
<path uri="/factory/wheel/{$wheel-id}">
<segment>factory</segment>
<segment>wheel</segment>
<variable-segment type="xs:string" maps-to-variable="wheel-id"/>
</path>
<method name="GET"/>
<produces>text/xml</produces>
<return-type>document-node()</return-type>
</function>
<!-- ... and much more ... -->
</functions>