@@ -88,35 +88,35 @@ Serializer is configurable but not replaceable! Type provider emit type with [Js
88
88
89
89
</Note >
90
90
91
- ``` fsharp {highlight:['9-10', '24 -28', '33-34']}
91
+ ``` fsharp {highlight:['20 -28', '33-34']}
92
92
open System
93
93
open SwaggerProvider
94
- open Newtonsoft.Json
94
+ open System.Text.Json
95
+ open System.Text.Json.Serialization
95
96
96
97
let [<Literal>] Schema = "https://petstore.swagger.io/v2/swagger.json"
97
98
type PetStore = OpenApiClientProvider<Schema, PreferAsync=true>
98
99
100
+ let jsonSerializerSettings =
101
+ // nuget: System.Text.Json
102
+ let settings = JsonSerializerOptions(
103
+ //PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
104
+ // ...
105
+ IgnoreNullValues = true
106
+ )
107
+ // nuget: FSharp.SystemTextJson
108
+ JsonFSharpOptions.Default().AddToJsonSerializerOptions settings
109
+ settings
110
+
99
111
type MyApiClient() =
100
112
// inherit from provided API client
101
113
inherit PetStore.Client()
102
114
103
- let jsonSerializerSettings =
104
- let settings =
105
- JsonSerializerSettings(
106
- NullValueHandling = NullValueHandling.Ignore,
107
- Formatting = Formatting.None)
108
- [ // Your custom JsonConverter's for F# types
109
- Swagger.Serialization.OptionConverter () :> JsonConverter
110
- Swagger.Serialization.ByteArrayConverter () :> JsonConverter
111
- ]
112
- |> List.iter settings.Converters.Add
113
- settings
114
-
115
115
// Overload default implementation of Serialize & Deserialize
116
116
override __.Serialize(value:obj): string =
117
- JsonConvert.SerializeObject (value, jsonSerializerSettings)
117
+ JsonSerializer.Serialize (value, jsonSerializerSettings)
118
118
override __.Deserialize(value, retTy:Type): obj =
119
- JsonConvert.DeserializeObject (value, retTy, jsonSerializerSettings)
119
+ JsonSerializer.Deserialize (value, retTy, jsonSerializerSettings)
120
120
121
121
122
122
[<EntryPoint>]
0 commit comments