AlgebraicJulia / ACSets.jl

ACSets: Algebraic databases as in-memory data structures
https://algebraicjulia.github.io/ACSets.jl/
MIT License
19 stars 8 forks source link

JSON Schema only use `$def` for selected types, need better way to reference other files #105

Open fivegrant opened 9 months ago

fivegrant commented 9 months ago

If I validate an object against a JSON Schema, it will check all $defs. This behavior ends up being too permissive since some types will be objects with arbitrary fields due to the Object InterType. This means nearly any JSON will validate against it which defeats the purpose of a JSON Schema.

A solution to this may be just selecting the InterTypes you want for the JSON Schema using its specific generate_module method's kwargs:

generate_module(mod, JSONTarget; exposed_intertypes=[:SomeType, :AnotherType])

Note that this isn't a problem with Pydantic since the constructor is called explicitly.

(Encountered this problem when reviewing this PR)

jpfairbanks commented 9 months ago

By introducing the exposed intertypes, those would be the ones that have specifications we could correctly validate, or those are the ones to permissively allow anything?

fivegrant commented 9 months ago

It would be the former. An "exposed" InterType is something we'd want to validate against.

fivegrant commented 9 months ago

Additionally, references are broken in the JSON Schema. Perhaps specifying a prefix like https://raw.githubusercontent.com/user/repo/some/path would add the path in front of all $refs

For JSON Schema to be usable, I think it has to support:

generate_module(mod, JSONTarget; exposed_intertypes=[:SomeType, :AnotherType], prefix="https://raw.githubusercontent.com/user/repo/some/path" )