Skip to content

Commit

Permalink
read defaults from openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Aug 5, 2022
1 parent 33daab0 commit ec440b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ components:
$ref: "./openapi/schemas/repository.yaml"
Item:
$ref: "./openapi/schemas/item.yaml"
Preferences:
$ref: "./openapi/schemas/preferences.yaml"
Error:
$ref: "./openapi/schemas/error.yaml"
parameters:
Expand Down
1 change: 0 additions & 1 deletion catalogues/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<entry xml:id="ODDversion">4.5.0</entry><!-- Versionsnummer der WeGA-ODD Schemata -->
<entry xml:id="versionNews">A050346</entry>
<entry xml:id="versionDate">2022-01-26</entry>
<entry xml:id="entriesPerPage">10</entry>
<entry xml:id="cmifID">e4c10c66-9b0b-4f2e-810c-669b0b2f2e20</entry>
</div>
<div xml:id="externalPNDResources">
Expand Down
19 changes: 9 additions & 10 deletions modules/config.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ declare function config:entries-per-page() as xs:int {
};

(:~
: Set user preferences and save to the current session
: Set user preferences and save to the current session.
: NB, no checks (for valid keys/values) are implemented here
: but should be present in the calling function
:
: @param $settings the new settings as map
: @return a map object like `map {
Expand Down Expand Up @@ -539,16 +541,13 @@ declare function config:set-preferences($settings as map(*)) as map(*) {
}`
:)
declare function config:get-preferences() as map(*) {
let $openapiPrefs := json-doc($config:openapi-config-path)?components?schemas?Preferences?properties
let $defaultSettings :=
map {
'line-wrap': true(),
'limit': config:get-option('entriesPerPage'),
'rdg-marker': false(),
'textConst-marker': true(),
'supplied-marker': true(),
'note-marker': true(),
'thematicCommentaries-marker': true()
}
map:merge(
for $pref in map:keys($openapiPrefs)
return
map:entry($pref, $openapiPrefs?($pref)?default)
)
let $sessionSettings := if(session:exists()) then session:get-attribute('preferences') else ()
return
if(exists($sessionSettings))
Expand Down

0 comments on commit ec440b7

Please sign in to comment.