aboutsummaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-12-20 17:58:34 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2025-02-19 18:54:25 +0100
commit91f4855d9479d4783562414a7aa6f3df7ae169ba (patch)
treeb8b96368712919d8226ac894b3b834806bfd05ac /frontend
parent0f838c2e3858e0f151f33412efc27c4701a434c5 (diff)
add parens around optional type union
Diffstat (limited to 'frontend')
-rw-r--r--frontend/app/Schema.hs31
1 files changed, 18 insertions, 13 deletions
diff --git a/frontend/app/Schema.hs b/frontend/app/Schema.hs
index 8c02a1a..cae9ed6 100644
--- a/frontend/app/Schema.hs
+++ b/frontend/app/Schema.hs
@@ -70,19 +70,24 @@ viewSchema :: Schema -> View action
viewSchema schema =
ol_ [] $
( \(k, v) ->
- li_ [] $
- [ text (toMisoString k),
- text ":",
- text
- ( case v of
- Type "string" (Just "date-time") -> "datetime"
- Type v Nothing -> toMisoString v
- Type v (Just f) -> toMisoString v <> " (" <> f <> ")"
- Reference v -> "reference to " <> toMisoString v
- Union vs -> Miso.String.intercalate " or " vs
- ),
- text (if k `S.member` schema.required then "" else "?")
- ]
+ let v' = case v of
+ Type "string" (Just "date-time") -> "datetime"
+ Type v Nothing -> toMisoString v
+ Type v (Just f) -> toMisoString v <> " (" <> f <> ")"
+ Reference v -> "reference to " <> toMisoString v
+ Union vs -> Miso.String.intercalate " or " vs
+ required = k `S.member` schema.required
+ in li_ [] $
+ [ text (toMisoString k),
+ text
+ ( ":"
+ <> ( if ' ' `T.elem` fromMisoString v' && not required
+ then "(" <> v' <> ")"
+ else v'
+ )
+ <> (if required then "" else "?")
+ )
+ ]
)
<$> (M.toList schema.properties)