Skip to content

Commit

Permalink
Add interactive OpenAPI documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mau Zsofia Abraham committed Jun 25, 2023
1 parent 806abc7 commit 3c09849
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
5 changes: 5 additions & 0 deletions deployment/initial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pushd lib/custom
curl -LO https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/12.2/Saxon-HE-12.2.jar
curl -LO https://repo1.maven.org/maven2/org/xmlresolver/xmlresolver/5.1.3/xmlresolver-5.1.3.jar
popd

pushd webapp
git clone https://github.com/acdh-oeaw/openapi4restxq
popd

if [ "$OSTYPE" == "msys" -o "$OSTYPE" == "win32" ]
then
cd bin
Expand Down
14 changes: 14 additions & 0 deletions expath-pkg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://expath.org/ns/pkg"
name="urn:vicav"
abbrev="vicav"
version="0.3.0"
spec="1.0"
xml:id="vicav">
<title>VICAV</title>
<dependency processor="http://basex.org" semver-min="9.2"/>
<xquery>
<namespace>urn:vicav</namespace>
<file>vicav.xqm</file>
</xquery>
</package>
33 changes: 33 additions & 0 deletions openapi-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="https://lab.sub.uni-goettingen.de/restxqopenapi">
<info>
<termsOfService>https://example.com/terms-of-use</termsOfService>
<contact>
<email>[email protected]</email>
</contact>
</info>
<servers>
<server url="http://localhost:8984/">Local development server</server>
<server url="https://vicav.acdh.oeaw.ac.at/">current ACDH-CH prod server</server>
<server url="https://vicav.acdh-ch-dev.oeaw.ac.at/vicav">current ACDH-CH dev server</server>
<server url="https://virtserver.swaggerhub.com/ctot-nondef/Vicav/1.0.0">SwaggerHub API Auto Mocking</server>
</servers>
<tags>
<tag name="noauth" method="exclusive">
Operations available without authentication
</tag>
</tags>
<!-- if you have any authentication: httpBasic info generation is implemented at the moment: >
<components>
<securitySchemes>
<securityScheme name="httpBasic">
This service uses HTTP Basic authentication.
<type>http</type>
<scheme>basic</scheme>
</securityScheme>
</securitySchemes>
</components>
<security>
<SecurityRequirement name="httpBasic"/>
</security> <!- -->
</config>
16 changes: 16 additions & 0 deletions repo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<meta xmlns="http://exist-db.org/xquery/repo">
<description>Vienna Corpus of Arabic Varieties</description>
<author>Austrian Centre for Digital Humanities</author>
<website>https://vicav.acdh.oeaw.ac.at</website>
<status>development</status>
<license ref="https://spdx.org/licenses/">MIT</license>
<copyright>true</copyright>
<type>application</type>
<target>vicav</target>
<changelog>
<change version="0.0.1">
<ul xmlns="http://www.w3.org/1999/xhtml"/>
</change>
</changelog>
</meta>
13 changes: 12 additions & 1 deletion vicav.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ declare namespace tei = 'http://www.tei-c.org/ns/1.0';
declare namespace dcterms = "http://purl.org/dc/terms/";
declare namespace prof = "http://basex.org/modules/prof";

import module namespace openapi="https://lab.sub.uni-goettingen.de/restxqopenapi" at "../openapi4restxq/content/openapi.xqm";

declare
%rest:path('/vicav/openapi.json')
%rest:produces('application/json')
%output:media-type('application/json')
function vicav:getOpenapiJSON() as item()+ {
openapi:json(file:base-dir())
};

declare function vicav:expandExamplePointers($in as item(), $dict as document-node()*) {
typeswitch ($in)
Expand Down Expand Up @@ -251,7 +260,9 @@ declare function vicav:transform($doc as element(), $xsltfn as xs:string, $print
let $stylePath := file:resolve-path('xslt/', file:base-dir())
let $style := doc(file:resolve-path('xslt/' || $xsltfn, file:base-dir()))

let $xslt := if (empty($print)) then $style else xslt:transform-text(doc(file:resolve-path('xslt/printable.xslt', file:base-dir())), doc(file:resolve-path('xslt/printable_path.xslt', file:base-dir())), map {'xslt': file:path-to-uri(file:resolve-path('xslt/' || $xsltfn, file:base-dir()))})
let $xslt := if (empty($print)) then $style else xslt:transform-text(
doc(file:resolve-path('xslt/printable.xslt', file:base-dir()))
, doc(file:resolve-path('xslt/printable_path.xslt', file:base-dir())), map {'xslt': file:path-to-uri(file:resolve-path('xslt/' || $xsltfn, file:base-dir()))})

let $sHTML := xslt:transform-text($doc, $xslt, $options)
return
Expand Down

0 comments on commit 3c09849

Please sign in to comment.