Skip to content

Schemas with https:// $schema URIs raise UnsupportedSchemaVersionError #97

@elias-ba

Description

@elias-ba

Summary

ExJsonSchema.Schema.resolve/1 rejects schemas whose $schema URI uses the https:// scheme, raising UnsupportedSchemaVersionError. Per the JSON Schema specification, $schema is an identifier, not a literal URL, and the official meta-schema is served over HTTPS at https://json-schema.org/draft-07/schema.

Reproduction

schema = %{
  "$schema" => "https://json-schema.org/draft-07/schema#",
  "type" => "object",
  "properties" => %{"name" => %{"type" => "string"}}
}

ExJsonSchema.Schema.resolve(schema)
#=> ** (ExJsonSchema.Schema.UnsupportedSchemaVersionError) Unsupported schema version, only draft 4, 6, and 7 are supported.

The same schema with http:// resolves cleanly.

Proposed fix

In lib/ex_json_schema/schema.ex, schema_module/2 and remote_schema/1 pattern-match on the http:// prefix only. A head clause that rewrites https://json-schema.org/... to http://json-schema.org/... before dispatch fixes both with no behavioural change for any other input. PR open at #98.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions