mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-10-08 13:38:39 +00:00
Some fixes to nullability (#365)
This commit is contained in:
@@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="myriad.toml"/>
|
<None Include="myriad.toml"/>
|
||||||
|
<Compile Include="JsonParseNullness.fs" />
|
||||||
|
<Compile Include="GeneratedJsonParseNullness.fs">
|
||||||
|
<MyriadFile>JsonParseNullness.fs</MyriadFile>
|
||||||
|
</Compile>
|
||||||
<Compile Include="AssemblyInfo.fs" />
|
<Compile Include="AssemblyInfo.fs" />
|
||||||
<Compile Include="RecordFile.fs"/>
|
<Compile Include="RecordFile.fs"/>
|
||||||
<Compile Include="GeneratedRecord.fs">
|
<Compile Include="GeneratedRecord.fs">
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -71,6 +71,7 @@ module JsonRecordType =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
||||||
|> Array.ofSeq
|
|> Array.ofSeq
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ module JsonRecordType =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
||||||
|> Array.ofSeq
|
|> Array.ofSeq
|
||||||
|
|
||||||
@@ -109,6 +111,7 @@ module JsonRecordType =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
@@ -201,7 +204,15 @@ module ToGetExtensionMethodJsonParseExtension =
|
|||||||
|
|
||||||
/// Parse from a JSON node.
|
/// Parse from a JSON node.
|
||||||
static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : ToGetExtensionMethod =
|
static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : ToGetExtensionMethod =
|
||||||
let arg_20 = System.Numerics.BigInteger.Parse (node.["whiskey"].ToJsonString ())
|
let arg_20 =
|
||||||
|
let v = node.["whiskey"]
|
||||||
|
|
||||||
|
System.Numerics.BigInteger.Parse (
|
||||||
|
(match v with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v)
|
||||||
|
.ToJsonString ()
|
||||||
|
)
|
||||||
|
|
||||||
let arg_19 =
|
let arg_19 =
|
||||||
(match node.["victor"] with
|
(match node.["victor"] with
|
||||||
|
53
ConsumePlugin/GeneratedJsonParseNullness.fs
Normal file
53
ConsumePlugin/GeneratedJsonParseNullness.fs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// This code was generated by myriad.
|
||||||
|
// Changes to this file will be lost when the code is regenerated.
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace ConsumePlugin
|
||||||
|
|
||||||
|
/// Module containing JSON parsing methods for the InnerStruct type
|
||||||
|
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
|
||||||
|
module InnerStruct =
|
||||||
|
/// Parse from a JSON node.
|
||||||
|
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : InnerStruct =
|
||||||
|
let arg_0 =
|
||||||
|
(match node.["a"] with
|
||||||
|
| null ->
|
||||||
|
raise (
|
||||||
|
System.Collections.Generic.KeyNotFoundException (
|
||||||
|
sprintf "Required key '%s' not found on JSON object" ("a")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
| v -> v)
|
||||||
|
.AsValue()
|
||||||
|
.GetValue<System.Int32> ()
|
||||||
|
|
||||||
|
{
|
||||||
|
A = arg_0
|
||||||
|
}
|
||||||
|
namespace ConsumePlugin
|
||||||
|
|
||||||
|
/// Module containing JSON parsing methods for the ArrayOfInnerStruct type
|
||||||
|
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
|
||||||
|
module ArrayOfInnerStruct =
|
||||||
|
/// Parse from a JSON node.
|
||||||
|
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : ArrayOfInnerStruct =
|
||||||
|
let arg_0 =
|
||||||
|
(match node.["b"] with
|
||||||
|
| null ->
|
||||||
|
raise (
|
||||||
|
System.Collections.Generic.KeyNotFoundException (
|
||||||
|
sprintf "Required key '%s' not found on JSON object" ("b")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
| v -> v)
|
||||||
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|
|> Seq.map (fun elt -> InnerStruct.jsonParse elt)
|
||||||
|
|> Array.ofSeq
|
||||||
|
|
||||||
|
{
|
||||||
|
B = arg_0
|
||||||
|
}
|
@@ -60,6 +60,7 @@ module GymOpeningHours =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
@@ -1038,6 +1039,7 @@ module Sessions =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> Visit.jsonParse elt)
|
|> Seq.map (fun elt -> Visit.jsonParse elt)
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
|
@@ -48,7 +48,16 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
return jsonNode.AsArray () |> Seq.map (fun elt -> Gym.jsonParse elt) |> List.ofSeq
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
|
return
|
||||||
|
jsonNode.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|
|> Seq.map (fun elt -> Gym.jsonParse elt)
|
||||||
|
|> List.ofSeq
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
|
|
||||||
@@ -82,6 +91,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return GymAttendance.jsonParse jsonNode
|
return GymAttendance.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -116,6 +130,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return GymAttendance.jsonParse jsonNode
|
return GymAttendance.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -146,6 +165,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return Member.jsonParse jsonNode
|
return Member.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -179,6 +203,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return Gym.jsonParse jsonNode
|
return Gym.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -209,6 +238,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return MemberActivityDto.jsonParse jsonNode
|
return MemberActivityDto.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -239,6 +273,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return UriThing.jsonParse jsonNode
|
return UriThing.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -294,6 +333,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return
|
return
|
||||||
match jsonNode with
|
match jsonNode with
|
||||||
| null -> None
|
| null -> None
|
||||||
@@ -346,6 +390,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return Sessions.jsonParse jsonNode
|
return Sessions.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -387,6 +436,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return Sessions.jsonParse jsonNode
|
return Sessions.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -878,6 +932,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return
|
return
|
||||||
new RestEase.Response<_> (
|
new RestEase.Response<_> (
|
||||||
responseString,
|
responseString,
|
||||||
@@ -914,6 +973,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return
|
return
|
||||||
new RestEase.Response<_> (
|
new RestEase.Response<_> (
|
||||||
responseString,
|
responseString,
|
||||||
@@ -950,6 +1014,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return
|
return
|
||||||
new RestEase.Response<_> (
|
new RestEase.Response<_> (
|
||||||
responseString,
|
responseString,
|
||||||
@@ -986,6 +1055,11 @@ module PureGymApi =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return
|
return
|
||||||
new RestEase.Response<_> (
|
new RestEase.Response<_> (
|
||||||
responseString,
|
responseString,
|
||||||
|
@@ -408,6 +408,7 @@ module InnerTypeWithBothJsonParseExtension =
|
|||||||
|
|
||||||
let value =
|
let value =
|
||||||
(kvp.Value).AsArray ()
|
(kvp.Value).AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Char> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Char> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
@@ -676,6 +677,7 @@ module JsonRecordTypeWithBothJsonParseExtension =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
||||||
|> Array.ofSeq
|
|> Array.ofSeq
|
||||||
|
|
||||||
@@ -689,6 +691,7 @@ module JsonRecordTypeWithBothJsonParseExtension =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
||||||
|> Array.ofSeq
|
|> Array.ofSeq
|
||||||
|
|
||||||
@@ -714,6 +717,7 @@ module JsonRecordTypeWithBothJsonParseExtension =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
|
@@ -94,6 +94,7 @@ module JwtVaultAuthResponse =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ module JwtVaultAuthResponse =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
@@ -120,6 +122,7 @@ module JwtVaultAuthResponse =
|
|||||||
)
|
)
|
||||||
| v -> v)
|
| v -> v)
|
||||||
.AsArray ()
|
.AsArray ()
|
||||||
|
|> Seq.cast<System.Text.Json.Nodes.JsonNode>
|
||||||
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
|> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
|
||||||
@@ -496,6 +499,11 @@ module VaultClient =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return JwtSecretResponse.jsonParse jsonNode
|
return JwtSecretResponse.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -532,6 +540,11 @@ module VaultClient =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return JwtVaultResponse.jsonParse jsonNode
|
return JwtVaultResponse.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -590,6 +603,11 @@ module VaultClientNonExtensionMethod =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return JwtSecretResponse.jsonParse jsonNode
|
return JwtSecretResponse.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -626,6 +644,11 @@ module VaultClientNonExtensionMethod =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return JwtVaultResponse.jsonParse jsonNode
|
return JwtVaultResponse.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -687,6 +710,11 @@ module VaultClientExtensionMethodHttpClientExtension =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return JwtSecretResponse.jsonParse jsonNode
|
return JwtSecretResponse.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
@@ -723,6 +751,11 @@ module VaultClientExtensionMethodHttpClientExtension =
|
|||||||
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let jsonNode =
|
||||||
|
match jsonNode with
|
||||||
|
| null -> raise (System.ArgumentNullException ())
|
||||||
|
| v -> v
|
||||||
|
|
||||||
return JwtVaultResponse.jsonParse jsonNode
|
return JwtVaultResponse.jsonParse jsonNode
|
||||||
}
|
}
|
||||||
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
|
||||||
|
13
ConsumePlugin/JsonParseNullness.fs
Normal file
13
ConsumePlugin/JsonParseNullness.fs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace ConsumePlugin
|
||||||
|
|
||||||
|
[<WoofWare.Myriad.Plugins.JsonParse>]
|
||||||
|
type InnerStruct =
|
||||||
|
{
|
||||||
|
A : int
|
||||||
|
}
|
||||||
|
|
||||||
|
[<WoofWare.Myriad.Plugins.JsonParse>]
|
||||||
|
type ArrayOfInnerStruct =
|
||||||
|
{
|
||||||
|
B : InnerStruct array
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
namespace WoofWare.Myriad.Plugins.Test
|
||||||
|
|
||||||
|
open System.Text.Json.Nodes
|
||||||
|
open FsUnitTyped
|
||||||
|
open NUnit.Framework
|
||||||
|
open ConsumePlugin
|
||||||
|
|
||||||
|
[<TestFixture>]
|
||||||
|
module TestJsonNullability =
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let ``Can consume JsonParseNullness`` () =
|
||||||
|
let options = JsonNodeOptions (PropertyNameCaseInsensitive = true)
|
||||||
|
|
||||||
|
"""{
|
||||||
|
"b": null
|
||||||
|
}"""
|
||||||
|
|> fun s -> JsonNode.Parse (s, options)
|
||||||
|
|> ArrayOfInnerStruct.jsonParse
|
||||||
|
|> shouldEqual
|
||||||
|
{
|
||||||
|
B = null
|
||||||
|
}
|
@@ -18,6 +18,7 @@
|
|||||||
<Compile Include="TestJsonParse\TestJsonParse.fs" />
|
<Compile Include="TestJsonParse\TestJsonParse.fs" />
|
||||||
<Compile Include="TestJsonParse\TestPureGymJson.fs" />
|
<Compile Include="TestJsonParse\TestPureGymJson.fs" />
|
||||||
<Compile Include="TestJsonParse\TestExtensionMethod.fs" />
|
<Compile Include="TestJsonParse\TestExtensionMethod.fs" />
|
||||||
|
<Compile Include="TestJsonParse\TestJsonNullability.fs" />
|
||||||
<Compile Include="TestHttpClient\TestPureGymRestApi.fs" />
|
<Compile Include="TestHttpClient\TestPureGymRestApi.fs" />
|
||||||
<Compile Include="TestHttpClient\TestPathParam.fs" />
|
<Compile Include="TestHttpClient\TestPathParam.fs" />
|
||||||
<Compile Include="TestHttpClient\TestReturnTypes.fs" />
|
<Compile Include="TestHttpClient\TestReturnTypes.fs" />
|
||||||
|
@@ -356,3 +356,19 @@ module internal AstHelper =
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
| _ -> failwithf "Failed to get record elements for type that was: %+A" repr
|
| _ -> failwithf "Failed to get record elements for type that was: %+A" repr
|
||||||
|
|
||||||
|
let raiseIfNull (variable : Ident) : SynExpr =
|
||||||
|
SynExpr.createMatch
|
||||||
|
(SynExpr.createIdent' variable)
|
||||||
|
[
|
||||||
|
SynMatchClause.create
|
||||||
|
SynPat.createNull
|
||||||
|
(SynExpr.applyFunction
|
||||||
|
(SynExpr.createIdent "raise")
|
||||||
|
(SynExpr.paren (
|
||||||
|
SynExpr.applyFunction
|
||||||
|
(SynExpr.createLongIdent [ "System" ; "ArgumentNullException" ])
|
||||||
|
(SynExpr.CreateConst ())
|
||||||
|
)))
|
||||||
|
SynMatchClause.create (SynPat.named "v") (SynExpr.createIdent "v")
|
||||||
|
]
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
namespace WoofWare.Myriad.Plugins
|
namespace WoofWare.Myriad.Plugins
|
||||||
|
|
||||||
open System.IO
|
|
||||||
open System.Net.Http
|
open System.Net.Http
|
||||||
open Fantomas.FCS.Syntax
|
open Fantomas.FCS.Syntax
|
||||||
open WoofWare.Whippet.Fantomas
|
open WoofWare.Whippet.Fantomas
|
||||||
@@ -14,17 +13,6 @@ type internal HttpClientGeneratorOutputSpec =
|
|||||||
module internal HttpClientGenerator =
|
module internal HttpClientGenerator =
|
||||||
open Fantomas.FCS.Text.Range
|
open Fantomas.FCS.Text.Range
|
||||||
|
|
||||||
let outputFile = FileInfo "/tmp/output.txt"
|
|
||||||
|
|
||||||
// do
|
|
||||||
// use _ = File.Create outputFile.FullName
|
|
||||||
// ()
|
|
||||||
|
|
||||||
let log (line : string) =
|
|
||||||
// use w = outputFile.AppendText ()
|
|
||||||
// w.WriteLine line
|
|
||||||
()
|
|
||||||
|
|
||||||
[<RequireQualifiedAccess>]
|
[<RequireQualifiedAccess>]
|
||||||
type PathSpec =
|
type PathSpec =
|
||||||
| Verbatim of string
|
| Verbatim of string
|
||||||
@@ -568,6 +556,9 @@ module internal HttpClientGenerator =
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let jsonNodeNotNull =
|
||||||
|
Let ("jsonNode", AstHelper.raiseIfNull (Ident.create "jsonNode"))
|
||||||
|
|
||||||
let setVariableHeaders =
|
let setVariableHeaders =
|
||||||
variableHeaders
|
variableHeaders
|
||||||
|> List.map (fun (headerName, callToGetValue) ->
|
|> List.map (fun (headerName, callToGetValue) ->
|
||||||
@@ -642,6 +633,7 @@ module internal HttpClientGenerator =
|
|||||||
yield responseString
|
yield responseString
|
||||||
yield responseStream
|
yield responseStream
|
||||||
yield jsonNode
|
yield jsonNode
|
||||||
|
yield jsonNodeNotNull
|
||||||
| String -> yield responseString
|
| String -> yield responseString
|
||||||
| Stream -> yield responseStream
|
| Stream -> yield responseStream
|
||||||
| UnitType ->
|
| UnitType ->
|
||||||
@@ -650,6 +642,7 @@ module internal HttpClientGenerator =
|
|||||||
| _ ->
|
| _ ->
|
||||||
yield responseStream
|
yield responseStream
|
||||||
yield jsonNode
|
yield jsonNode
|
||||||
|
yield jsonNodeNotNull
|
||||||
]
|
]
|
||||||
|> SynExpr.createCompExpr "async" returnExpr
|
|> SynExpr.createCompExpr "async" returnExpr
|
||||||
|> SynExpr.startAsTask cancellationTokenArg
|
|> SynExpr.startAsTask cancellationTokenArg
|
||||||
@@ -914,10 +907,6 @@ module internal HttpClientGenerator =
|
|||||||
"Create a REST client. The input functions will be re-evaluated on every HTTP request to obtain the required values for the corresponding header properties."
|
"Create a REST client. The input functions will be re-evaluated on every HTTP request to obtain the required values for the corresponding header properties."
|
||||||
|> PreXmlDoc.create
|
|> PreXmlDoc.create
|
||||||
|
|
||||||
let functionName = Ident.create "client"
|
|
||||||
|
|
||||||
let pattern = SynLongIdent.createS "make"
|
|
||||||
|
|
||||||
let returnInfo = SynType.createLongIdent interfaceType.Name
|
let returnInfo = SynType.createLongIdent interfaceType.Name
|
||||||
|
|
||||||
let nameWithoutLeadingI =
|
let nameWithoutLeadingI =
|
||||||
|
@@ -78,6 +78,7 @@ module internal JsonParseGenerator =
|
|||||||
/// collectionType is e.g. "List"; we'll be calling `ofSeq` on it.
|
/// collectionType is e.g. "List"; we'll be calling `ofSeq` on it.
|
||||||
/// body is the body of a lambda which takes a parameter `elt`.
|
/// body is the body of a lambda which takes a parameter `elt`.
|
||||||
/// {assertNotNull node}.AsArray()
|
/// {assertNotNull node}.AsArray()
|
||||||
|
/// |> Seq.cast<JsonNode>
|
||||||
/// |> Seq.map (fun elt -> {body})
|
/// |> Seq.map (fun elt -> {body})
|
||||||
/// |> {collectionType}.ofSeq
|
/// |> {collectionType}.ofSeq
|
||||||
let asArrayMapped
|
let asArrayMapped
|
||||||
@@ -91,6 +92,13 @@ module internal JsonParseGenerator =
|
|||||||
| None -> node
|
| None -> node
|
||||||
| Some propertyName -> assertNotNull propertyName node
|
| Some propertyName -> assertNotNull propertyName node
|
||||||
|> SynExpr.callMethod "AsArray"
|
|> SynExpr.callMethod "AsArray"
|
||||||
|
|> SynExpr.pipeThroughFunction (
|
||||||
|
SynExpr.createLongIdent [ "Seq" ; "cast" ]
|
||||||
|
|> SynExpr.typeApp
|
||||||
|
[
|
||||||
|
SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ]
|
||||||
|
]
|
||||||
|
)
|
||||||
|> SynExpr.pipeThroughFunction (
|
|> SynExpr.pipeThroughFunction (
|
||||||
SynExpr.applyFunction (SynExpr.createLongIdent [ "Seq" ; "map" ]) (SynExpr.createLambda "elt" body)
|
SynExpr.applyFunction (SynExpr.createLongIdent [ "Seq" ; "map" ]) (SynExpr.createLambda "elt" body)
|
||||||
)
|
)
|
||||||
@@ -273,10 +281,12 @@ module internal JsonParseGenerator =
|
|||||||
)
|
)
|
||||||
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Map" ; "ofSeq" ])
|
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Map" ; "ofSeq" ])
|
||||||
| BigInt ->
|
| BigInt ->
|
||||||
node
|
AstHelper.raiseIfNull (Ident.create "v")
|
||||||
|
|> SynExpr.paren
|
||||||
|> SynExpr.callMethod "ToJsonString"
|
|> SynExpr.callMethod "ToJsonString"
|
||||||
|> SynExpr.paren
|
|> SynExpr.paren
|
||||||
|> SynExpr.applyFunction (SynExpr.createLongIdent [ "System" ; "Numerics" ; "BigInteger" ; "Parse" ])
|
|> SynExpr.applyFunction (SynExpr.createLongIdent [ "System" ; "Numerics" ; "BigInteger" ; "Parse" ])
|
||||||
|
|> SynExpr.createLet [ SynBinding.basic [ Ident.create "v" ] [] node ]
|
||||||
| Measure (_measure, primType) ->
|
| Measure (_measure, primType) ->
|
||||||
parseNumberType options propertyName node primType
|
parseNumberType options propertyName node primType
|
||||||
|> SynExpr.pipeThroughFunction (Measure.getLanguagePrimitivesMeasure primType)
|
|> SynExpr.pipeThroughFunction (Measure.getLanguagePrimitivesMeasure primType)
|
||||||
|
Reference in New Issue
Block a user