Marklogic Rest 资源扩展不支持 metadata.xml

Marklogic Rest Resource extension not honoring metadata.xml

我有一个 rest 资源扩展,我在其中指定了参数类型。但是我注意到我在 POST 或 GET 中获得的参数与我的参数类型不同metadata.xml..都是xs:string。但是当我查看开箱即用的搜索 API 时,它确实支持参数类型。我进行了更深入的挖掘,我注意到在 /MarkLogic/rest-api/endpoints/config.xqyget-rsrc-list-query-rule() 没有获取我在 metadata.xml 中指定的元数据规则,但对于开箱即用的搜索 rest api,它确实获得了正确的规则..

declare function conf:get-rsrc-list-query-rule() as element(rest:request) {
    <rest:request
            allow-post-alias="true"
            fast-match="/*/config/resources"
            uri="^/(v1|get-rsrc-list-query-ruleLATEST)/config/resources/?$"
            endpoint="/MarkLogic/rest-api/endpoints/resource-list-query.xqy">
        <rest:http method="GET">
            <rest:param name="format"  required="false" values="json|xml"/>
            <rest:param name="refresh" required="false" as="boolean"/>
        </rest:http>
    </rest:request>
};

而对于开箱即用的搜索休息 api,已发送正确的规则

declare function conf:get-search-query-request-rule() as element(rest:request) {
    <rest:request
            allow-post-alias="true"
            fast-match="/*/search"
            uri="^/(v1|LATEST)/search(/)?$"
            endpoint="/MarkLogic/rest-api/endpoints/search-list-query.xqy"
            user-params="allow-dups">
        <rest:http method="GET">
            <rest:param  name="q" required="false"/>
            <rest:param name="format" required="false" values="json|xml"/>
            <rest:param  name="start"  as="unsignedLong" required="false"/>
            <rest:param  name="pageLength" as="unsignedLong"  required="false"/>
            <rest:param name="category" required="false" repeatable="true"
                values="content|metadata|{string-join(docmodcom:list-metadata-categories(),"|")}"/>
            <rest:param  name="options" as="string"  required="false"/>
            <rest:param  name="collection" as="string"  required="false" repeatable="true"/>
            <rest:param  name="directory" as="string"  required="false" repeatable="false"/>
            <rest:param  name="view" as="string" values="metadata|results|facets|all|none"/>
            <rest:param  name="txid" as="string" required="false"/>
            <rest:param name="database"     required="false"/>
            <rest:param  name="transform" required="false"/>
            <rest:param  name="structuredQuery" required="false"/>
            <rest:auth>
              <rest:privilege>http://marklogic.com/xdmp/privileges/rest-reader</rest:privilege>
              <rest:kind>execute</rest:kind>
            </rest:auth>
        </rest:http>
        <rest:http method="POST">
            <rest:param  name="q" required="false"/>
            <rest:param name="format" required="false" values="json|xml"/>
            <rest:param name="category" required="false" repeatable="true"
                values="content|metadata|{string-join(docmodcom:list-metadata-categories(),"|")}"/>
            <rest:param  name="start"  as="unsignedLong" required="false"/>
            <rest:param  name="pageLength" as="unsignedLong"  required="false"/>
            <rest:param  name="options" as="string"  required="false"/>
            <rest:param  name="collection" as="string"  required="false" repeatable="true"/>
            <rest:param  name="directory" as="string"  required="false" repeatable="false"/>
            <rest:param  name="view" as="string" values="metadata|results|facets|all|none"/>
            <rest:param  name="txid" as="string" required="false"/>
            <rest:param name="database"     required="false"/>
            <rest:param  name="transform" required="false"/>
            <rest:content-type>text/xml</rest:content-type>
            <rest:content-type>text/json</rest:content-type>
            <rest:content-type>application/xml</rest:content-type>
            <rest:content-type>application/json</rest:content-type>
            <rest:auth>
              <rest:privilege>http://marklogic.com/xdmp/privileges/rest-reader</rest:privilege>
              <rest:kind>execute</rest:kind>
            </rest:auth>
        </rest:http>
        <rest:http method="HEAD"/>
        <rest:http method="OPTIONS"/>
    </rest:request>
};

我以为当我指定我的参数类型时,资源剩余 api 将强制执行类型,否则会引发错误,但事实并非如此。它与开箱即用休息api。

我是不是没看懂?我弄错了吗?我如何告诉其余资源扩展遵守我在 metadata.xml

中指定的参数类型

元数据是有关资源服务扩展的可选信息,您可以获取该信息以了解可用的扩展。

文档是这样说的:

"If the extension service expects parameters, you can optionally 'declare' the parameters using request parameters when installing the extension. This information is metadata that can be returned by a GET request to /config/resources. It is not used to check parameters on requests to the extension."

http://docs.marklogic.com/guide/rest-dev/extensions#id_59112

"MarkLogic Server returns a summary of the installed extensions in XML or JSON.... The amount of information available about a given extension depends on the amount of metadata provided during installation of the extension."

http://docs.marklogic.com/guide/rest-dev/extensions#id_73853

您可以将字符串转换为扩展中的任何类型,例如通过调用 xs:int() 或 xs:double()。

希望对您有所帮助,