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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/reference.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#:*http-read-timeout*
#:*http-connect-timeout*
#:fetch-schema
#:store-reference

;; conditions
#:remote-reference-error
Expand Down Expand Up @@ -375,6 +376,18 @@
:uri uri)))


(defun store-reference (parsed-schema)
"Takes a parsed schema from json-schema.parse:parse and inserts it into the context. The parsed schema should have a reasonable id defined in it. This function is helpful when you want to load a bunch of schemas, but don't want to allow network access."
(flet ((store-schema (uri schema)
(setf (gethash uri (context-references *context*)) schema)
(populate-named-references-for-schema schema
:id-fun #'default-id-fun
:uri (quri:uri uri))
schema))
(store-schema (default-id-fun parsed-schema) parsed-schema)))



(defun fetch-reference (uri)
"Fetches a schema and adds it to the current context as a side effect."
(flet ((store-schema (schema)
Expand Down