18 questions
2
votes
0
answers
114
views
Using JsonSchema.Net to validate JSON when the JSON schema references other schemas
I'm trying to use the JsonSchema.Net library to validate JSON objects.
For example, I have these schemas: the main schema AddressChangedEvent.schema.json that references both EventHeader.schema.json ...
1
vote
1
answer
77
views
JsonSchema.net doesnt contain errors when evaluating an invalid document against CycloneDX schema
I'm using nuget package JsonSchema.Net 7.3.4 in a .Net 8 application to validate a json document against the official CycloneDX 1.6 Json schema (https://cyclonedx.org/schema/bom-1.6.schema.json).
The ...
1
vote
1
answer
57
views
Is it possible to validate that default value type matches property type on the json schema?
var jsonSchema = @"{
""$schema"": ""https://json-schema.org/draft/2020-12/schema"",
""type"": ""...
2
votes
1
answer
110
views
How to make members with the required keyword (C# 11) be required in JSON schemas generated by json-schema builder?
I've been exploring the use of C# 11’s required members feature in conjunction with JSON schema generation. Specifically, I'm using the JsonSchemaBuilder class (from the JsonEverything library) to ...
2
votes
1
answer
73
views
JsonPath.Net - use query to flatten data structure
Using JsonPath.Net, is it possible to write a single query that will obtain the values of properties with the same key at different nesting levels?
For example, from the following JSON:
{
"ObjA&...
0
votes
1
answer
53
views
jsonpath.net - identify string matches in descendants of dissimilar objects
Considering the following example JSON:
{
"SH1": {
"Locations": [
{
"Downstream Device": [
{
...
-1
votes
1
answer
196
views
JSONPath "$[length(@.foo)]" fails to return array length when tested via json-everything library
This seems like a simple use case. We are trying to obtain the number of items in an array using the JSONPath function length().
The test object is:
{
"array": [1,2,3]
}
The JSONPath ...
0
votes
0
answers
72
views
JSON Path - return array element satisfying regex AND string match condition with JsonPath.net
I am using system.text.json.nodes with JsonPath.net.
I have an array of four Json objects:
[
{
"Action" : [
{
"value" : "Home"
...
0
votes
2
answers
2k
views
Validating JSON data against my schema in C# using JsonSchema.Net
I'm evaluating the JsonSchema.Net and trying to figure out how to validate data during deserialization.
For reference, I am using a simple Person model, like this:
using Json.Schema.Generation;
...
-1
votes
2
answers
210
views
Json Path - get all but last element of an array
I have a JSON array:
[
1,
2,
3,
4
]
I want to create a Json Path expression that returns all but the last element of the array, i.e. the result is:
[
1,
2,
3
]
There are ...
1
vote
1
answer
290
views
Plugging JsonSchema.Net into ASP.NET Core for validation
We want to make use of JsonSchema.Net to validate json sent to ASP.NET Core endpoints (Minimal APIs). Results for failures must also be returned in the RFC ProblemDetails format. This is doable but ...
1
vote
1
answer
639
views
JsonRequired vs Required Attribute for generating Json Schemas
.NET 8,
Nuget Package JsonSchema.Net.Generation
According to the docs, the [Required] attribute can be used to make a property 'required' when generating a Json Schema from a C# class.
However, for de-...
0
votes
1
answer
248
views
JsonSchemaBuilder.FromType<T>().Build() does not execute IAttributeHandlers
I'm evaluating Json.Schema to generate json schemas from my typed objects in .net for sharing validation between client and server.
I have a super simple implementation called from a unit test.
var ...
0
votes
0
answers
397
views
Generate Custom JSON Schema using JsonSchema.Net.Generation
We are using JsonSchema.Net.Generation (C#, dotNet 5.0) and I would like generate a custom JSON schema based on the properties and its attributes of a class which has category attribute set. How do I ...
0
votes
1
answer
774
views
JsonSchema.Net stops validation at first property with inappropriate error
I have JSON schema generated using JsonSchema.Net.Generation. My classes for schema are as below:
class PaymentInitiationSchema
{
[Required]
[JsonPropertyName("type")]
public ...