ex_json_schema icon indicating copy to clipboard operation
ex_json_schema copied to clipboard

Possible internal reference resolution issue

Open raif-s-naffah opened this issue 8 years ago • 4 comments

When trying to resolve a schema (available here), I get the following error:

    ** (ExJsonSchema.Schema.InvalidSchemaError) invalid reference #verb#languagemap
        (ex_json_schema) lib/ex_json_schema/schema.ex:119: ExJsonSchema.Schema.get_fragment/2
        (ex_json_schema) lib/ex_json_schema/schema.ex:110: ExJsonSchema.Schema.resolve_ref/2
        (ex_json_schema) lib/ex_json_schema/schema.ex:98: ExJsonSchema.Schema.resolve_property/3
        (ex_json_schema) lib/ex_json_schema/schema.ex:73: anonymous fn/3 in ExJsonSchema.Schema.do_resolve/3
        (stdlib) lists.erl:1263: :lists.foldl/3
...

Replacing the $ref values w/ #/properties/xxx instead of #xxx seems to get me past this issue but others arise.

I'm unsure whether this is a bug, a limitation or something wrong I'm [not] doing?

raif-s-naffah avatar Apr 29 '17 00:04 raif-s-naffah

I have seen this when attempting to $ref to an id that has a local pointer such as "#uuid".

technomage avatar Jun 08 '17 18:06 technomage

FWIW i worked around this issue by modifying the schema document i'm parsing by:

  • replacing the properties property at the top level w/ definitions to follow best practices,
  • replacing all $ref property values to be of the form #/definitions/xxx,
  • removing any id property present at the top level of referenced schema definitions.

w/ those changes the schema is parsed correctly and i'm able to validate against it.

raif-s-naffah avatar Jun 09 '17 00:06 raif-s-naffah

local references to id of definitions does not appear to work.

technomage avatar Jun 09 '17 22:06 technomage

Thanks for reporting this, I will have to look into it. To be honest, the whole part about using ids to change the resolution scope and referencing to them is the most confusing part about the whole specification for me. No idea yet how easy this would be to fix.

jonasschmidt avatar Jun 11 '17 07:06 jonasschmidt