Skip to content

Commit

Permalink
fix cli version detection/support for draft6
Browse files Browse the repository at this point in the history
  • Loading branch information
andreineculau committed May 8, 2022
1 parent ac9f44a commit ae9348b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/jesse_cli.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

%%%_* API ======================================================================

-include("jesse_schema_validator.hrl").

main([]) ->
main(["--help"]);
main(["-h"]) ->
Expand Down Expand Up @@ -104,9 +106,15 @@ add_schemata([SchemaFile|Rest]) ->

maybe_fill_schema_id(SchemaFile, Schema) ->
SchemaFqdn = "file://" ++ filename:absname(SchemaFile),
case jesse_json_path:value(<<"id">>, Schema, undefined) of
undefined ->
[ {<<"id">>, unicode:characters_to_binary(SchemaFqdn)}
Version = jesse_json_path:value(<<"$schema">>, Schema, undefined),
Id = jesse_lib:get_schema_id(Schema),
case {Version, Id} of
{?json_schema_draft6, undefined} ->
[ {?ID, unicode:characters_to_binary(SchemaFqdn)}
| Schema
];
{_, undefined} ->
[ {?ID_OLD, unicode:characters_to_binary(SchemaFqdn)}
| Schema
];
_ ->
Expand Down

0 comments on commit ae9348b

Please sign in to comment.