Comments (18)
Try
var schema = JsonSchema4.FromJson(File.ReadAllText(...));
from njsonschema.
I thought it will just read the plain json text instead of schema . I will check and get back to you then .
Thanks for your quick help.
from njsonschema.
Hi Rico Suter,
Somehow this feature is not working for me with the version 1.22.5836.1197. I have created two sample json files stored in C:\Test folder as below.
C:\Test\Person.json
{
"type": "object",
"properties": {
"name": { "type": "string" },
"addresses": {
"type": "array",
"items": { "$ref": "address.json" }
}
}
}
C:\Test\address.json
{
"type": "object",
"properties": {
"street": {"type": "string"},
"city": {"type": "string"}
}
}
then I have created one sample tests as below.
var schema = JsonSchema4.FromJson(File.ReadAllText(@"c:\test\person.json"));
var data = JToken.Parse(File.ReadAllText(@"c:\test\data.json"));
var errors = schema.Validate(data);
First line throws exception
An unhandled exception of type 'System.NotSupportedException' occurred in NJsonSchema.dll
Additional information: Could not resolve the path 'address.json' because JSON file references are not supported.
Am I doing something wrong?. Please look into it.
from njsonschema.
I think file references are not supported yet. I have to check the code tomorrow if there's an easy way to do this...
from njsonschema.
Okay, thanks for quick reply. It will be great help since it is part of Draft 4 Schema specs & we cant have large schema files.
from njsonschema.
Ok, its fixed now in 1.23, please try again
from njsonschema.
Thanks. I will try with the latest 1.24 version. Does it supports web references?
from njsonschema.
No, not yet. But i can add this too...
from njsonschema.
Do you mean an absolute web references which starts either with "http" or "https"?
from njsonschema.
Okay thanks for quick reply :).
Yes exactly.
from njsonschema.
Tried with same sample using 1.24 but it is throwing exception
Could not resolve the path 'address.json' because no root path is available.
from njsonschema.
You need to load it using the new method JsonSchema4.FromFile()
from njsonschema.
... otherwise the file path is not known by the parser (as stated by the exception).
from njsonschema.
Yes... sorry my bad.. tried with FromFile(), it is working.
Cheers!!!
from njsonschema.
v1.25 now supports now supports URL references...
from njsonschema.
Thanks it is working.
from njsonschema.
have you provided any class for n/w proxy settings?
from njsonschema.
sorry, I don't understand your question?
from njsonschema.
Related Issues (20)
- Question: Retrieve JSON Schema definition for a Json Element/Node?
- System.MissingMethodException: Method not found: 'Void NJsonSchema.JsonSchema.set_Type(NJsonSchema.JsonObjectType) HOT 1
- Bug: Public Fields not showing up when using System.Text.Json
- Values set in custom Schema Processor are overwritten during schema generation
- CSharpClientGenerator and CSharpGenerator not working together
- Using the generic type 'JsonInheritanceConverter<TBase>' requires 1 type argument HOT 2
- NJsonSchema generated code throwing The JSON value could not be converted HOT 1
- Improve base package readme
- AllowAdditionalProperties - not working
- Format "guid" vs "uuid"
- Validation Failures On All JSON Schema Draft Versions
- Private expression-bodied read-only properties should be ignored HOT 1
- Unable to generate document when XmlElement[] is a property of the class
- JsonProperty not working on version 11.0.0 (working on 10.9.0) HOT 1
- Referenced schema could not be loaded when defined in external schema file
- Fixed the bug. "System.InvalidOperationException: Could not resolve the path '#/paths/~1audienceCategories~1%7Ba "
- Annotations on separate lines?
- Polymorphic Schema Generation
- .Net6 to .Net8 upgrade - System.InvalidOperationException: This operation is only valid on generic types. HOT 1
- C# TimeSpan not resolved and generated as a DayJs duration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from njsonschema.