Gitlab Community Edition Instance

Skip to content
Snippets Groups Projects
Commit 29b96eb7 authored by Mark Rainbird's avatar Mark Rainbird
Browse files

Changes for Fusion compatability

Existing application does not work with Fusion due to different
implementation of collection function. Fusion does not return non-XML
content such as XQuery files which means the endpoints are not
found. There is also a function name clash in openapi-tests-simple.xqm
which creates an error in Fusion with the sample endpoints.

Issue is resolved with recursive functions that use xmldb functions  in
order to find child resources and collections to build the list of uris in
place of existing base-uri function. This works in both Fusion and eXist

There is also an extension to the list of recognised xquery file
extensions to cover other used formats.
parent edf6b2fc
Branches develop
No related tags found
No related merge requests found
Pipeline #169678 passed
......@@ -210,7 +210,7 @@ as element(test) {
declare
%rest:POST("{$body}")
%rest:path("/openapi-test/simple/multi-function")
function openapi-test-simple:multi-post($body)
function openapi-test-simple:multi-post-function($body)
as element(test) {
<test>
<parameters n="0"/>
......@@ -226,7 +226,7 @@ as element(test) {
declare
%rest:POST("{$body}")
%rest:path("/openapi-test/simple/multi-module")
function openapi-test-simple:multi-post($body)
function openapi-test-simple:multi-post-module($body)
as element(test) {
<test>
<parameters n="0"/>
......
......@@ -34,7 +34,7 @@ as xs:string {
:)
declare function openapi:main($target as xs:string)
as map(*) {
let $modules-uris := collection($target)[openapi:xquery-resource(string(base-uri()))]/base-uri()
let $modules-uris := openapi:files($target, ())[openapi:xquery-resource(.)]
let $module :=
for $module in $modules-uris
let $test4rest := contains(util:binary-doc($module) => util:base64-decode(), "%rest:")
......@@ -420,4 +420,42 @@ as xs:boolean {
ends-with($baseuri, ".xqm")
or ends-with($baseuri, ".xql")
or ends-with($baseuri, ".xq")
or ends-with($baseuri, ".xquery")
or ends-with($baseuri, ".xqy")
};
(:~
: Returns the names of the child resources in collection URI supplied
: @param $target URI under which child resources are to be returned :)
declare function openapi:files-uris($target as xs:string) {
let $new-uris as xs:string* := xmldb:get-child-resources($target)
let $new-uris as xs:string* :=
for $n in $new-uris return fn:concat($target, '/', $n)
return $new-uris
};
(:~
: Returns the names of the child collections in collection URI supplied
: @param $target URI under which collections are to be returned :)
declare function openapi:collections-uris($target as xs:string) {
let $collections as xs:string* := xmldb:get-child-collections($target)
return $collections
};
(:~
: Recursive function to use instead of collection as implementation of this function
: varies between Fusion and eXist so in Fusion XQuery files are not found.
: @param $target URI under which file listing is required
: @param $uris Existing URIs to be retained and added to until completion :)
declare function openapi:files($target as xs:string, $uris as xs:string*) {
let $current-uris as xs:string* := openapi:files-uris($target)
let $current-collections as xs:string* := openapi:collections-uris($target)
let $new-uris as xs:string* :=
if (fn:empty($current-collections)) then ()
else
for $c in $current-collections
let $target := fn:concat($target, '/', $c)
return (openapi:files($target, $uris))
let $uris as xs:string* := ($current-uris, $new-uris, $uris)
return ($uris)
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment