Gitlab Community Edition Instance

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • subugoe/openapi4restxq
  • mark.rainbird/openapi4restxq
2 results
Show changes
Commits on Source (11)
# tempaltes
.install_template: &installation
script:
# wait for service container
- while [ $(curl --head --silent http://$TARGET | grep -c "200 OK") == 0 ]; do sleep 2s; done
# upload package
- 'curl -X PUT -H "Content-Type: application/zip" --data-binary @$(ls build/*.xar) "http://admin:@$TARGET/exist/rest/db/openapi.xar"'
# install package
- 'curl -X GET "http://admin:@$TARGET/exist/rest/db/?_query=repo:install-and-deploy-from-db(''/db/openapi.xar'')"'
# check availabilty
# for debug use - 'curl --silent "http://$TARGET/exist/apps/openapi/openapi.json"'
- 'curl --silent "http://$TARGET/exist/apps/openapi/index.html" | grep "Swagger UI for OpenAPI for RESTXQ"' # swagger available
- 'curl --silent "http://$TARGET/exist/apps/openapi/openapi.json" | grep "OpenAPI for RESTXQ"' # openapi.json available
timeout: 5 minutes
# main CI instructions
image: docker.gitlab.gwdg.de/subugoe/openapi4restxq:latest
stages:
......@@ -12,11 +28,10 @@ build-develop:
stage: build
script:
- npm install
- ant test
- ant
artifacts:
paths:
- build/*.xar
- test/
build-main:
only:
......@@ -31,24 +46,29 @@ build-main:
- build/*.xar
- test/
installation:
installation-exist:
except:
- tags
stage: test
script:
- bash test/eXist-db-*/bin/startup.sh | tee output.log &
# wait for eXist
- while [ $(curl --head --silent http://localhost:8080 | grep -c "200 OK") == 0 ]; do sleep 2s; done
# shutdown eXist
- bash test/eXist-db-*/bin/shutdown.sh
- ls -al /tmp; mv /tmp/tests-* . || true
artifacts:
paths:
- output.log
- test/tests-*.xml
- test/eXist-db-*/webapp/WEB-INF/logs/expath-repo.log
reports:
junit: test/tests-*.xml
services:
- name: existdb/existdb:latest
alias: existdb
variables:
TARGET: "existdb:8080"
<<: *installation
installation-fusion:
stage: test
except:
- tags
services:
- name: repo.evolvedbinary.com:9443/evolvedbinary/fusiondb-server:latest
alias: fusiondb
variables:
TARGET: "fusiondb:4059"
<<: *installation
upload:
only:
......
......@@ -13,7 +13,8 @@ OpenAPI conform documentation. It covers the RESTXQ annotations as well as the
[xqDocs](http://xqdoc.org/xqdoc_comments_doc.html) for describing the API.
It is meant to be used for a single [expath package](http://expath.org/spec/pkg)
and written for [eXist-db](http://exist-db.org).
and written for [eXist-db](http://exist-db.org), but supports [fusiondb](http://fusiondb.com)
as well.
## Build
For preparing the `openapi.json` the application is build with
......
project.name=https://lab.sub.uni-goettingen.de/openapi4restxq-develop
project.version=1.6.0
project.version=1.7.0
project.title=OpenAPI for RESTXQ
project.abbrev=openapi-develop
project.processorversion=4.6.1
project.processorversion=5.2.0
destfile=${build.dir}/${project.abbrev}-${project.version}.xar
test.dir=test
......@@ -57,13 +57,19 @@ Run `npm install` first to build a package that includes swagger-ui.</echo>
</target>
<target name="test" depends="antversion-test, xar">
<!-- task setpermissions requries at least ant 1.10.0 -->
<get src="https://bintray.com/existdb/releases/download_file?file_path=eXist-db-${project.processorversion}.tar.bz2" dest="${build.dir}/eXist-db-${project.processorversion}.tar.bz2" skipexisting="true" />
<untar src="${build.dir}/eXist-db-${project.processorversion}.tar.bz2" dest="${test.dir}" compression="bzip2" />
<setpermissions mode="755">
<file file="${test.dir}/eXist-db-${project.processorversion}/bin/startup.sh"/>
</setpermissions>
<copy file="${destfile}" todir="${test.dir}/eXist-db-${project.processorversion}/autodeploy" />
</target>
<delete dir="${test.dir}"/>
<get src="https://bintray.com/existdb/releases/download_file?file_path=exist-distribution-${project.processorversion}-unix.tar.bz2" dest="${build.dir}/eXist-${project.processorversion}.tar.bz2" skipexisting="true" quiet="true" />
<untar src="${build.dir}/eXist-${project.processorversion}.tar.bz2" dest="${test.dir}" compression="bzip2">
<cutdirsmapper dirs="1" />
</untar>
<setpermissions mode="755">
<fileset dir="${test.dir}">
<filename name="bin/*.sh"/>
</fileset>
</setpermissions>
<copy file="${destfile}" todir="${test.dir}/autodeploy" />
</target>
</project>
......@@ -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:resources($target, ())[openapi:xquery-resource(.)]
let $module :=
for $module in $modules-uris
let $test4rest := contains(util:binary-doc($module) => util:base64-decode(), "%rest:")
......@@ -316,7 +316,7 @@ as map(*)* {
declare %private function openapi:mediaType-object($function)
as map(*) {
let $produces := (
$function/annotation[@name="rest:produces"]/string(value),
$function/annotation[@name="rest:produces"]/value/string(),
string($function/annotation[@name="output:media-type"]),
string($function/annotation[@name="output:method"]/openapi:method-mediaType(string(.))),
"application/xml"
......@@ -379,7 +379,7 @@ as map(*) {
:)
declare function openapi:spdx($licenseId as xs:string)
as map(*) {
let $collection-uri := /id("restxqopenapi")/base-uri()
let $collection-uri := collection()/id("restxqopenapi")/base-uri()
let $item :=
(($collection-uri || "/../spdx-licenses.json")
=> json-doc())("licenses")?*[?licenseId = $licenseId]
......@@ -415,9 +415,47 @@ as map(*)* {
! map{ "example": .}
};
declare function openapi:xquery-resource($baseuri as xs:string)
declare %private function openapi:xquery-resource($baseuri as xs:string)
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 %private function openapi:resource-uris($target as xs:string)
as item()* {
xmldb:get-child-resources($target) ! ($target || '/' || .)
};
(:~
: Returns the names of the child collections in collection URI supplied
: @param $target URI under which collections are to be returned :)
declare %private function openapi:collections-uris($target as xs:string)
as item()* {
xmldb:get-child-collections($target)
};
(:~
: Recursive function to use instead of collection as implementation of this function
: varies between Fusion and eXist so in Fusion XQuery resources are not found.
: @param $target URI under which resource listing is required
: @param $uris Existing URIs to be retained and added to until completion :)
declare %private function openapi:resources($target as xs:string, $uris as xs:string*)
as item()* {
let $current-uris as xs:string* := openapi:resource-uris($target)
let $current-collections as xs:string* := openapi:collections-uris($target)
let $new-uris as xs:string* :=
if (empty($current-collections)) then ()
else
for $collection in $current-collections
let $target := $target || '/' || $collection
return openapi:resources($target, $uris)
let $uris as xs:string* := ($current-uris, $new-uris, $uris)
return
$uris
};
......@@ -8,6 +8,16 @@
<type>application</type>
<target>openapi</target>
<changelog>
<change version="1.7.0">
<ul xmlns="http://www.w3.org/1999/xhtml">
<li class="feat">Features
<ul style="margin-left: 15px;">
<li>add compatibility to <a href="http://fusiondb.com">fusiondb</a></li>
<li>move ci test stage to service container</li>
</ul>
</li>
</ul>
</change>
<change version="1.6.0">
<ul xmlns="http://www.w3.org/1999/xhtml">
<li class="bugs">Bugfix
......
This diff is collapsed.