|
40 | 40 | return schema.Evaluate(instance);
|
41 | 41 | }
|
42 | 42 | }
|
| 43 | + solution: |- |
| 44 | + var schema = JsonSerializer.Deserialize<JsonSchema>(schemaText); |
43 | 45 | tests:
|
44 | 46 | - instance: { "foo": 13, "bar": "a string" }
|
45 | 47 | isValid: true
|
|
54 | 56 | - instance: 6.8
|
55 | 57 | isValid: false
|
56 | 58 | - id: 26b6ebca-58e6-4824-86ea-4946d844c9a8
|
57 |
| - skip: true |
| 59 | + skip: true # source gen is not available in dynamic compilation |
58 | 60 | background: |
|
59 | 61 | JSON Schema is typically itself represented in JSON. To support this, the `JsonSchema`
|
60 | 62 | type is completely compatible with the _System.Text.Json_ serializer.
|
|
102 | 104 | }
|
103 | 105 |
|
104 | 106 | /* USER CODE */
|
| 107 | + solution: |- |
| 108 | + [JsonSerializable(typeof(JsonSchema))] |
| 109 | + [JsonSerializable(typeof(EvaluationResults))] |
| 110 | + internal partial class MySerializerContext : JsonSerializerContext; |
105 | 111 | tests:
|
106 | 112 | - instance: { "foo": 13, "bar": "a string" }
|
107 | 113 | isValid: true
|
|
148 | 154 | return schema.Evaluate(instance);
|
149 | 155 | }
|
150 | 156 | }
|
| 157 | + solution: |- |
| 158 | + builder.Type(SchemaValueType.String); |
151 | 159 | tests:
|
152 | 160 | - instance: a string value
|
153 | 161 | isValid: true
|
|
191 | 199 | return schema.Evaluate(instance);
|
192 | 200 | }
|
193 | 201 | }
|
| 202 | + solution: |- |
| 203 | + builder.Type(SchemaValueType.String) |
| 204 | + .ExclusiveMinimum(0) |
| 205 | + .Maximum(10); |
194 | 206 | tests:
|
195 | 207 | - instance: 6.8
|
196 | 208 | isValid: true
|
|
250 | 262 | return schema.Evaluate(instance);
|
251 | 263 | }
|
252 | 264 | }
|
| 265 | + solution: |- |
| 266 | + builder.Type(SchemaValueType.Array) |
| 267 | + .Items(new JsonSchemaBuilder().Type(SchemaValueType.Integer)) |
| 268 | + .MaxItems(5); |
253 | 269 | tests:
|
254 | 270 | - instance: 6.8
|
255 | 271 | isValid: false
|
|
305 | 321 | return schema.Evaluate(instance, options);
|
306 | 322 | }
|
307 | 323 | }
|
| 324 | + solution: |- |
| 325 | + options.RequireFormatValidation = true; |
308 | 326 | tests:
|
309 | 327 | - instance: 2015-06-13T10:31:16+04:00
|
310 | 328 | format: date-time
|
|
409 | 427 | return schema.Evaluate(instance, options);
|
410 | 428 | }
|
411 | 429 | }
|
| 430 | + solution: |- |
| 431 | + var options = new EvaluationOptions { EvaluateAs = specVersion }; |
412 | 432 | tests:
|
413 | 433 | - instance: [{},4]
|
414 | 434 | version: Draft6
|
|
0 commit comments