You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
testCase "ProblemDetailsModel serializes validation problem details"
125
+
<|fun _ ->
126
+
letserializer= JsonSerializer():> IJsonSerializer
127
+
leterrors= Dictionary<string, string array>()
128
+
errors.Add("Name",[|"The Name field is required."|])
129
+
130
+
letmodel=
131
+
{ Type ="https://tools.ietf.org/html/rfc7231#section-6.5.1"
132
+
Title ="One or more validation errors occurred."
133
+
Status =400
134
+
Detail =null
135
+
Instance =null
136
+
Errors = errors
137
+
TraceId ="00-abc-123-00"}
138
+
139
+
letjson= serializer.Serialize(model)
140
+
141
+
Expect.isTrue
142
+
(json.Contains("\"errors\":{\"Name\":[\"The Name field is required.\"]}"))
143
+
"Errors should serialize"
144
+
145
+
Expect.isTrue (json.Contains("\"traceId\":\"00-abc-123-00\""))"TraceId should serialize"
146
+
117
147
testCase "ProblemDetailsModel deserializes known fields"
118
148
<|fun _ ->
119
149
letserializer= JsonSerializer():> IJsonSerializer
@@ -129,6 +159,29 @@ let tests =
129
159
Expect.equal model.Detail "Missing.""Detail should deserialize"
130
160
Expect.equal model.Instance "/companies/99""Instance should deserialize"
131
161
162
+
testCase "ProblemDetailsModel deserializes validation problem details"
163
+
<|fun _ ->
164
+
letserializer= JsonSerializer():> IJsonSerializer
165
+
166
+
letjson=
167
+
"{\"type\":\"https://tools.ietf.org/html/rfc7231#section-6.5.1\",\"title\":\"One or more validation errors occurred.\",\"status\":400,\"errors\":{\"Name\":[\"The Name field is required.\"]},\"traceId\":\"00-abc-123-00\"}"
0 commit comments