Skip to content

$ref to a yaml schema fails to resolve #668

@danfelicetta-RL

Description

@danfelicetta-RL

Given a schema in yaml, which references a sub-schema also in yaml, e.g.:

$id: resource:/schema
type: object
properties:
  foo:
    $ref: foo.yml

foo.yml

type: object

validate will fail because the resolution of the reference will attempt to parse foo.yml as if it were json:

Caused by: com.networknt.schema.JsonSchemaException: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'type': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (BufferedInputStream); line: 1, column: 6]
	at app//com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:396)
	at app//com.networknt.schema.RefValidator.getRefSchema(RefValidator.java:79)
	at app//com.networknt.schema.RefValidator.<init>(RefValidator.java:42)

the same example with the sub-schema in json will work as expected:

$id: resource:/schema
type: object
properties:
  foo:
    $ref: foo.json

foo.json

{"type": "object"}

should retrieving a schema from a URI attempt to detect the format as yaml and parse it as such?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions