Skip to content

Allow parsed schemas to be stored directly into the context. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryanobjc
Copy link

Schema sets are sometimes entirely on disk, and we don't want to visit the network, or perhaps the URI doesn't even load. This function will allow the program to parse and store schemas.

Schema sets are sometimes entirely on disk, and we don't want to visit
the network, or perhaps the URI doesn't even load.  This function will
allow the program to parse and store schemas.
@fisxoj
Copy link
Owner

fisxoj commented Jul 13, 2024

Thanks for the PR!

I've been trying to think about this and how I'd like it to fit with the API in general. Do you mind sharing how you use it? Are you only adding a single schema or would it be more useful if you could add many files?

@ryanobjc
Copy link
Author

My code works something like this:

(defun load-all-schemas (&optional (path-pattern "~/json-schemas/**/*.json"))
  (json-schema.reference:with-context (*context*)
    (loop for p in (directory path-pattern)
          do (json-schema.reference:store-reference (json-schema.parse:parse p)))))

something like that.

In my case, the schemas I'm working with aren't formally published so it's impossible to retrieve them from the URIs provided. I have about 30 files here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants