YouValidateMe JSON Schema library server project built on this library #169
Replies: 3 comments 1 reply
-
@crowdwave happy to hear that you might want to try this has some new features. note that api is slightly different since it is major version bump |
Beta Was this translation helpful? Give feedback.
-
as per specification if the schema does not has |
Beta Was this translation helpful? Give feedback.
-
in your project you run the server:
so you want to read all schema files only from the path specified by user and you don't want to expose any system file path to user. with we want to introduce custom url for this; for example type dirLoader string
func (l dirLoader) Load(url string) (any, string) {
path, ok := strings.CutPrefix(url, "schemas:///")
if !ok {
return nil, fmt.Errorf("unsupported url: %v", url)
}
path = filepath.join(string(l), path)
f, err := os.Open(path)
if err!=nil {
return nil, err
}
defer f.Close()
return jsonschema.UnmarshalJSON(f)
}
func testLoader() {
c := jsonschema.NewCompiler()
c.DefaultDraft(jsonschema.Draft6)
c.useLoader(dirLoader("/path/to/schemas"))
// to compile a particular schema
c.Compile("schemas:///dir1/dir2/test.json")
} |
Beta Was this translation helpful? Give feedback.
-
Hello I thought you might be interested, I built a JSON schema library server and it is using your library for its core.
https://github.com/crowdwave/youvalidateme
I started with a different JSON Schema library for Go but I switched to yours as your has more features and seems more actively maintained.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions