Skip to content

Can't find the correct way to use SchemaStorage #435

Closed
@ghost

Description

Due to a lack of understanding on my part and also the rather slim documentation, I am forced to ask about the proper way to use SchemaStorage here.

I want to have a parent schema in place, located at https://myurl.com/schema/parentschema.schema.json and then multiple schemata, each inheriting the constraints from parentschema at the top level. I.e., the parentschema looks something like

{
  "param1": { "type": "integer" },
  "param2": { "type": "string" }
}

and the subschemas all look something like

{
  "$ref": "https://myurl.com/schema/parentschema.schema.json",
  "required": ["param1"]
}

adding only their own respective required structure to the schema.

I am trying to use SchemaStorage like

$schema = file_get_contents(__DIR__ . "/../schema/subschema.schema.json");

$schemaStorage = new SchemaStorage();
$schemaStorage->addSchema(__DIR__ . "/../schema/parentschema.schema.json", json_decode($schema));

$fac = new Factory($schemaStorage);
$validator = new Validator($fac);

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