Skip to content

Loading a json schema from classpath. Fail to resolve $ref #854

@avishaybp81

Description

@avishaybp81

I load a schema from the classpath.

private JsonSchema getJsonSchemaFromClasspath(String name) {
    JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
    InputStream is = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(name);
    return factory.getSchema(is);
}

If there is a $ref in the schema that looks like the below

"metadata": {
  "$ref": "request_metadata.json"
}

I fail to load the schema with the error below.
Caused by: com.networknt.schema.JsonSchemaException: #/properties/metadata/$ref: Reference request_metadata.json cannot be resolved

any idea how to solve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions