You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thanks again for Exonerate! I mentioned the issue of working with compressed (gzipped) schemas at CodeBEAM America, and Isaac suggested I open an issue.
I have a bunch of schemas that are wordy but compress nicely (5-6x smaller). I currently end up generating the validators like this (code and names have been changed and simplified to protect the innocent).
defmodule CompressedReaderHelper do
defmacro __using__(_env) do
res = File.stream!(Path.join(__DIR__, "schema.json.gz"), [:read, :compressed]) |> Enum.into("")
quote do
require Exonerate
Exonerate.function_from_string( :def, :function_name, unquote(res))
end
end
end
(I actually wrote it this way so I could use CompressedReaderHelper and pass some extra parameters to change the schema file path for different modules, but that's not pertinent to the compression).
I think it would be pretty straightforward to conditionally pass the :compressed option and replace File.read! with File.stream! in function_from_file
but I am not experienced enough in Elixir to know if it's stylistically a poor choice to push this into the opts parameter that's already there but used for an entirely different set of options.
The text was updated successfully, but these errors were encountered:
ivanov
changed the title
allow reading compressed schemas
allow reading gzip compressed schemas
Mar 19, 2024
thanks again for Exonerate! I mentioned the issue of working with compressed (gzipped) schemas at CodeBEAM America, and Isaac suggested I open an issue.
I have a bunch of schemas that are wordy but compress nicely (5-6x smaller). I currently end up generating the validators like this (code and names have been changed and simplified to protect the innocent).
(I actually wrote it this way so I could
use CompressedReaderHelper
and pass some extra parameters to change the schema file path for different modules, but that's not pertinent to the compression).I think it would be pretty straightforward to conditionally pass the
:compressed
option and replaceFile.read!
withFile.stream!
infunction_from_file
Exonerate/lib/exonerate.ex
Line 427 in 1a63956
but I am not experienced enough in Elixir to know if it's stylistically a poor choice to push this into the
opts
parameter that's already there but used for an entirely different set of options.The text was updated successfully, but these errors were encountered: