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
68bf4f06
Commit
68bf4f06
authored
6 years ago
by
Mathias Goebel
Browse files
Options
Downloads
Patches
Plain Diff
allow customized tags
parent
d68b165d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
content/openapi.xqm
+28
-10
28 additions, 10 deletions
content/openapi.xqm
openapi-config.xml
+7
-0
7 additions, 0 deletions
openapi-config.xml
with
35 additions
and
10 deletions
content/openapi.xqm
+
28
−
10
View file @
68bf4f06
...
@@ -51,10 +51,10 @@ as map(*) {
...
@@ -51,10 +51,10 @@ as map(*) {
return
return
map
:
merge
((
map
:
merge
((
map
{
"openapi"
:
"3.0.2"
}
,
map
{
"openapi"
:
"3.0.2"
}
,
openapi:paths-object
(
$module
)
,
openapi:paths-object
(
$module
,
$config
)
,
openapi:servers-object
(
$config
/
openapi:servers
)
,
openapi:servers-object
(
$config
/
openapi:servers
)
,
openapi:info-object
(
$expath
,
$repo
,
$config
/
openapi:info
)
,
openapi:info-object
(
$expath
,
$repo
,
$config
/
openapi:info
)
,
openapi:tags-object
(
$module
)
openapi:tags-object
(
$module
,
$config
)
))
))
};
};
...
@@ -127,7 +127,7 @@ as map(*) {
...
@@ -127,7 +127,7 @@ as map(*) {
: Prepare OAS3 Paths Object.
: Prepare OAS3 Paths Object.
: @see https://swagger.io/specification/#pathsObject
: @see https://swagger.io/specification/#pathsObject
:)
:)
declare
%private
function
openapi:paths-object
(
$module
as
element
(
module
)
+
)
declare
%private
function
openapi:paths-object
(
$module
as
element
(
module
)
+
,
$config
as
element
(
openapi:config
)
)
as
map
(
*
)
{
as
map
(
*
)
{
let
$paths
:=
$module
/
function
/
annotation
[
@name
=
"rest:path"
]
/
value
=>
distinct-values
()
let
$paths
:=
$module
/
function
/
annotation
[
@name
=
"rest:path"
]
/
value
=>
distinct-values
()
return
return
...
@@ -139,7 +139,7 @@ as map(*) {
...
@@ -139,7 +139,7 @@ as map(*) {
return
return
map
{
map
{
$path
=>
replace
(
"\{\$"
,
"{"
)
:
$path
=>
replace
(
"\{\$"
,
"{"
)
:
map
:
merge
((
$functions
!
openapi:operation-object
(
.
)))
map
:
merge
((
$functions
!
openapi:operation-object
(
.
,
$config
)))
}
}
))
))
}
}
...
@@ -149,12 +149,23 @@ as map(*) {
...
@@ -149,12 +149,23 @@ as map(*) {
: Prepare OAS3 Operation Object.
: Prepare OAS3 Operation Object.
: @see https://swagger.io/specification/#operationObject
: @see https://swagger.io/specification/#operationObject
:)
:)
declare
%private
function
openapi:operation-object
(
$function
as
element
(
function
))
declare
%private
function
openapi:operation-object
(
$function
as
element
(
function
)
,
$config
as
element
(
openapi:config
)
)
as
map
(
*
)
{
as
map
(
*
)
{
let
$desc
:=
normalize-space
(
$function
/
description
)
let
$name
:=
$function
/
@name
let
$desc
:=
tokenize
(
$function
/
description
,
"\n\s\n\s"
)
!
normalize-space
(
.
)
let
$see
:=
normalize-space
(
$function
/
see
)
let
$see
:=
normalize-space
(
$function
/
see
)
let
$deprecated
:=
$function
/
deprecated
let
$deprecated
:=
$function
/
deprecated
let
$tags
:=
array
{
$function
/
@name
=>
substring-before
(
":"
)
}
let
$tags
:=
array
{
if
(
$config
/
openapi:tags
/
openapi:tag
/
openapi:function
[
@name
=
$name
])
then
if
(
$config
/
openapi:tags
/
openapi:tag
/
openapi:function
[
@name
=
$name
]
/
parent
::
openapi:tag
/
string
(
@method
)
=
"exclusive"
)
then
$config
/
openapi:tags
/
openapi:tag
/
openapi:function
[
@name
=
$name
]
/
parent
::
openapi:tag
[
@method
=
"exclusive"
]
/
string
(
@name
)
else
(
$name
=>
substring-before
(
":"
)
,
$config
/
openapi:tags
/
openapi:tag
/
openapi:function
[
@name
=
$name
]
/
parent
::
openapi:tag
/
string
(
@name
))
else
$name
=>
substring-before
(
":"
)
}
return
return
map
:
merge
((
map
:
merge
((
for
$method
in
$function
/
annotation
[
@name
=
$openapi:supported-methods
]
/
substring-after
(
lower-case
(
@name
)
,
"rest:"
)
for
$method
in
$function
/
annotation
[
@name
=
$openapi:supported-methods
]
/
substring-after
(
lower-case
(
@name
)
,
"rest:"
)
...
@@ -162,7 +173,8 @@ as map(*) {
...
@@ -162,7 +173,8 @@ as map(*) {
map
{
map
{
$method
:
$method
:
map
:
merge
((
map
:
merge
((
map
{
"description"
:
$desc
}
,
map
{
"summary"
:
$desc
[
1
]}
,
map
{
"description"
:
$desc
[
2
]}
,
map
{
"tags"
:
$tags
}
,
map
{
"tags"
:
$tags
}
,
$see
[
1
]
!
map
{
"externalDocs"
:
$see
!
map
{
$see
[
1
]
!
map
{
"externalDocs"
:
$see
!
map
{
"url"
:
.,
"url"
:
.,
...
@@ -336,7 +348,7 @@ as map(*)? {
...
@@ -336,7 +348,7 @@ as map(*)? {
}
}
};
};
declare
%private
function
openapi:tags-object
(
$modules
as
element
(
module
)
+
)
declare
%private
function
openapi:tags-object
(
$modules
as
element
(
module
)
+
,
$config
as
element
(
openapi:config
)
)
as
map
(
*
)
{
as
map
(
*
)
{
map
{
map
{
"tags"
:
array
{
"tags"
:
array
{
...
@@ -345,8 +357,14 @@ as map(*) {
...
@@ -345,8 +357,14 @@ as map(*) {
map
{
map
{
"name"
:
string
(
$module
/
@prefix
)
,
"name"
:
string
(
$module
/
@prefix
)
,
"description"
:
normalize-space
(
$module
/
description
)
"description"
:
normalize-space
(
$module
/
description
)
}
,
for
$tag
in
$config
/
openapi:tags
/
openapi:tag
return
map
{
"name"
:
string
(
$tag
/
@name
)
,
"description"
:
normalize-space
(
$tag
)
}
}
}
}
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
openapi-config.xml
+
7
−
0
View file @
68bf4f06
...
@@ -10,4 +10,11 @@
...
@@ -10,4 +10,11 @@
<server
url=
"http://localhost:8080/exist/restxq"
>
Local development server
</server>
<server
url=
"http://localhost:8080/exist/restxq"
>
Local development server
</server>
<server
url=
"https://example.com/api/v1"
>
Production server
</server>
<server
url=
"https://example.com/api/v1"
>
Production server
</server>
</servers>
</servers>
<tags>
<tag
name=
"public"
method=
"exclusive"
>
The public part of the API. No authentication. World-readable.
<function
name=
"openapi-test-simple:del"
/>
<function
name=
"openapi-test-simple:get"
/>
</tag>
</tags>
</config>
</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