From 4560138b593f62109b20df47c03467e5e5f045e5 Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Mon, 21 Apr 2025 20:49:32 +0100 Subject: [PATCH] Work around a strange Gitea behaviour (#370) --- WoofWare.Myriad.Plugins/Swagger.fs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/WoofWare.Myriad.Plugins/Swagger.fs b/WoofWare.Myriad.Plugins/Swagger.fs index 90e4ef4..9cb6b62 100644 --- a/WoofWare.Myriad.Plugins/Swagger.fs +++ b/WoofWare.Myriad.Plugins/Swagger.fs @@ -198,7 +198,19 @@ and ObjectTypeDefinition = |> Map.ofSeq |> Some - let example = asObjOpt node "example" + let example = + match node.["example"] with + | null -> None + | :? JsonObject as o -> Some o + | :? JsonValue as s -> + // Gitea returns a stringified JSON object here, which from my limited reading is + // against the spec. + match JsonNode.Parse (s.GetValue ()) with + | null -> + // JSON null value; :shrug: + None + | n -> n.AsObject () |> Some + | _ -> failwith "expected `example` key to be a JSON object" let required = asArrOpt' node "required"