Gitlab Community Edition Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openapi4restxq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
subugoe
openapi4restxq
Commits
5b69a6fa
Commit
5b69a6fa
authored
6 years ago
by
Mathias Goebel
Browse files
Options
Downloads
Plain Diff
Merge branch 'release/1.1.0'
parents
9040438c
defba25d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
build.properties
+1
-1
1 addition, 1 deletion
build.properties
content/openapi-tests-simple.xqm
+66
-0
66 additions, 0 deletions
content/openapi-tests-simple.xqm
content/openapi.xqm
+37
-29
37 additions, 29 deletions
content/openapi.xqm
openapi-config.xml
+1
-0
1 addition, 0 deletions
openapi-config.xml
with
105 additions
and
30 deletions
build.properties
+
1
−
1
View file @
5b69a6fa
project.name
=
https://lab.sub.uni-goettingen.de/openapi4restxq-develop
project.version
=
1.
0.2
project.version
=
1.
1.0
project.title
=
OpenAPI for RESTXQ
project.abbrev
=
openapi-develop
project.processorversion
=
4.6.0
...
...
This diff is collapsed.
Click to expand it.
content/openapi-tests-simple.xqm
+
66
−
0
View file @
5b69a6fa
...
...
@@ -25,6 +25,72 @@ as element(test) {
</test>
};
(:~
: Simple GET Method Test with HEADER parameter for OpenAPI
: @param $test A string added to the request header “x-test”
: @return xml fragment that describes request and response
: @see http://example.com/documentation/about/this
:)
declare
%rest:GET
%rest:path
(
"/openapi-test/simple/get-header"
)
%rest:header-param
(
"x-test"
,
"{$test}"
)
function
openapi-test-simple:get-header
(
$test
as
xs:string
*
)
as
element
(
test
)
{
<test>
<parameters
n=
"1"
>
<header>
{
$test
}
</header>
</parameters>
<response
n=
"1"
type=
"application/xml"
/>
</test>
};
(:~
: Simple GET Method Test with COOKIE parameter for OpenAPI
: @param $test A string added to the request header “x-test”
: @return xml fragment that describes request and response
: @see http://example.com/documentation/about/this
:)
declare
%rest:GET
%rest:path
(
"/openapi-test/simple/get-cookie"
)
%rest:cookie-param
(
"tasty_cookie"
,
"{$test}"
)
function
openapi-test-simple:get-cookie
(
$test
as
xs:string
*
)
as
element
(
test
)
{
<test>
<parameters
n=
"1"
>
<cookie>
{
$test
}
</cookie>
</parameters>
<response
n=
"1"
type=
"application/xml"
/>
</test>
};
(:~
: Simple GET Method Test with multiple parameter for OpenAPI
: @param $test A string added to the request header “x-test”
: @return xml fragment that describes request and response
: @see http://example.com/documentation/about/this
:)
declare
%rest:GET
%rest:path
(
"/openapi-test/simple/get-multi"
)
%rest:query-param
(
"getTest1"
,
"{$getTest1}"
)
%rest:query-param
(
"getTest2"
,
"{$getTest2}"
)
%rest:cookie-param
(
"tasty_cookie"
,
"{$cookieTest}"
)
%rest:header-param
(
"x-test"
,
"{$headerTest}"
)
function
openapi-test-simple:get-cookie
(
$getTest1
as
xs:string
*,
$getTest2
as
xs:string
*,
$cookieTest
as
xs:string
*,
$headerTest
as
xs:string
*
)
as
element
(
test
)
{
<test>
<parameters
n=
"4"
>
<header>
{
$headerTest
}
</header>
<cookie>
{
$cookieTest
}
</cookie>
<get1>
{
$getTest1
}
</get1>
<get2>
{
$getTest2
}
</get2>
</parameters>
<response
n=
"1"
type=
"application/xml"
/>
</test>
};
(:~
: Simple but deprecated GET Method Test for OpenAPI
...
...
This diff is collapsed.
Click to expand it.
content/openapi.xqm
+
37
−
29
View file @
5b69a6fa
...
...
@@ -112,14 +112,14 @@ as map(*) {
declare
%private
function
openapi:servers-object
(
$config
as
element
(
openapi:servers
))
as
map
(
*
)
{
map
{
"servers"
:
[
"servers"
:
array
{
for
$server
in
$config
/
openapi:server
return
map
{
"url"
:
string
(
$server
/
@url
)
,
"description"
:
string
(
$server
)
}
]
}
}
};
...
...
@@ -195,7 +195,7 @@ if(not(exists($function/annotation[@name = ("rest:POST", "rest:PUT")]/value))) t
};
(:~
: Prepare OAS3 Response Object.
: Prepare OAS3 Response
s
Object.
: @see https://swagger.io/specification/#responsesObject
: :)
declare
%private
function
openapi:responses-object
(
$function
as
element
(
function
))
...
...
@@ -213,14 +213,16 @@ as map(*){
(:~
: Prepare OAS3 Parameter Object.
: @see https://swagger.io/specification/#
mediaType
Object
: @see https://swagger.io/specification/#
parameter
Object
: :)
declare
%private
function
openapi:parameter-object
(
$function
as
element
(
function
))
as
map
(
*
)
{
map
{
"parameters"
:
array
{
openapi:parameters-path
(
$function
)
,
openapi:parameters-query
(
$function
)
openapi:parameters
(
$function
,
"query"
)
,
openapi:parameters
(
$function
,
"header"
)
,
openapi:parameters
(
$function
,
"cookie"
)
}
}
};
...
...
@@ -228,6 +230,7 @@ as map(*) {
(:~
: Prepares all PATH parameters for a given function
: @param $function A function element from the inspect module
: @see https://swagger.io/specification/#parameterObject
: :)
declare
%private
function
openapi:parameters-path
(
$function
as
element
(
function
))
as
map
(
*
)
*
{
...
...
@@ -258,30 +261,33 @@ as map(*)* {
};
(:~
: Prepares all QUERY parameters for a given function
: Prepares all QUERY
, HEADER and COOKIE
parameters for a given function
: @param $function A function element from the inspect module
: @see https://swagger.io/specification/#parameterObject
: :)
declare
%private
function
openapi:parameters
-query
(
$function
as
element
(
function
))
declare
%private
function
openapi:parameters
(
$function
as
element
(
function
)
,
$source
as
xs:string
)
as
map
(
*
)
*
{
let
$queryParameters
:=
$function
/
annotation
[
@name
=
"rest:query-param"
]
for
$parameter
in
$queryParameters
let
$name
:=
string
(
$parameter
/
value
[
2
])
=>
replace
(
"\{|\$|\}"
,
""
)
let
$argument
:=
$function
/
argument
[
@var
eq
$name
]
let
$required
:=
exists
(
$parameter
/
value
[
3
]
and
not
(
contains
(
$argument
/
@cardinality
,
"zero"
)))
let
$basics
:=
map
:
merge
((
map
{
"name"
:
$name
,
"in"
:
"query"
,
"required"
:
$required
}
,
openapi:schema-object
(
$argument
)
let
$parameters
:=
$function
/
annotation
[
@name
=
"rest:"
||
$source
||
"-param"
]
for
$annotation
in
$parameters
let
$varName
:=
string
(
$annotation
/
value
[
2
])
=>
replace
(
"\{|\$|\}"
,
""
)
let
$name
:=
string
(
$annotation
/
value
[
1
])
let
$argument
:=
$function
/
argument
[
@var
eq
$varName
]
let
$required
:=
(: when a default value is present and the cardinality is not ? or * :)
exists
(
$annotation
/
value
[
3
])
and
not
(
contains
(
$argument
/
@cardinality
,
"zero"
))
let
$basics
:=
map
:
merge
((
map
{
"name"
:
$name
,
"in"
:
$source
,
"required"
:
$required
}
,
openapi:schema-object
(
$argument
)
))
let
$description
:=
$function
/
argument
[
@var
=
$name
]
/
text
()
!
map
{
"description"
:
.
}
let
$pos
:=
index-of
((
$function
/
argument
/
string
(
@var
))
,
$name
)
let
$example
:=
openapi:example
(
$function
,
$name
)
return
map
:
merge
((
$basics
,
$description
,
$example
))
let
$description
:=
$argument
/
text
()
!
map
{
"description"
:
.
}
let
$example
:=
openapi:example
(
$function
,
$varName
)
return
map
:
merge
((
$basics
,
$description
,
$example
))
};
(:~
...
...
@@ -309,14 +315,16 @@ as map(*) {
: @see https://swagger.io/specification/#mediaTypeObject
: :)
declare
%private
function
openapi:schema-object
(
$returns
as
element
(
*
))
as
map
(
*
)
{
map
{
"schema"
:
as
map
(
*
)
?
{
map
{
"schema"
:
map
:
merge
((
map
{
"type"
:
"string"
,
"x-xml-type"
:
string
(
$returns
/
@type
)
}
,
if
(
contains
(
$returns
/
@cardinality
,
"zero"
))
then
map
{
"nullable"
:
true
()
}
else
()
if
(
contains
(
$returns
/
@cardinality
,
"zero"
))
then
map
{
"nullable"
:
true
()
}
else
()
))
}
};
...
...
@@ -374,6 +382,6 @@ as xs:string?{
: @param $name The name of the argument to prepare an example for :)
declare
%private
function
openapi:example
(
$function
as
element
(
function
)
,
$name
as
xs:string
)
as
map
(
*
)
*
{
string
(
$function
/
annotation
[
@name
=
"test:arg"
][
value
[
1
]
=
$name
]
/
value
[
2
])
string
(
$function
/
annotation
[
@name
=
"test:arg"
][
value
[
1
]
eq
$name
]
/
value
[
2
])
!
map
{
"example"
:
.
}
};
This diff is collapsed.
Click to expand it.
openapi-config.xml
+
1
−
0
View file @
5b69a6fa
...
...
@@ -8,5 +8,6 @@
</info>
<servers>
<server
url=
"http://localhost:8080/exist/restxq"
>
Local development server
</server>
<server
url=
"https://example.com/api/v1"
>
Production server
</server>
</servers>
</config>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment