jonasschmidt / ex_json_schema

An Elixir JSON Schema validator
MIT License
366 stars 98 forks source link

Make schema domain configurable #76

Open ghost opened 2 years ago

ghost commented 2 years ago

We are hosting the schema itself so it would be nice if the schema domain can be configurable. Now we get the following error:

Unsupported schema version, only draft 4, 6, and 7 are supported.

If we host it on for example: http://json-schema.test.docker/draft-07/schema

Suggested code at lib/ex_json_schema/schema.ex#L37

  @current_draft_schema_url Application.get_env(:ex_json_schema, :schema_host, "http://json-schema.org/schema")
  @draft4_schema_url @current_draft_schema_url <> "/draft-04/schema"
  @draft6_schema_url @current_draft_schema_url <> "/draft-06/schema"
  @draft7_schema_url @current_draft_schema_url <> "/draft-07/schema"

Thanks in advance

jonasschmidt commented 2 years ago

Hey, so I don't really get the use case for this. The draft schemas are bundled in the lib and will not be fetched over the network. Why would you want to provide your own, identical schemas that have to be fetched remotely? I think there's also a bunch of other functions that match on the schema that won't work out of the box.