Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace $ref with resolved content before checking enum #134

Open
Ninos opened this issue Sep 11, 2023 · 0 comments
Open

Replace $ref with resolved content before checking enum #134

Ninos opened this issue Sep 11, 2023 · 0 comments

Comments

@Ninos
Copy link

Ninos commented Sep 11, 2023

Seems that the $ref is not resolved correctly, if used in sub-properties.

My schema looks something like this:

{
    "type": "string",
    "format": "select",
    "enum": {
        "$ref": "/some/example/subPath"
    }
}

After validating, I get following error:

enum must be a non-empty array

My validator looks very "primitive":

$resolver = new SomeCustomResolver();
$schemaLoader = new SchemaLoader(null, $resolver);
$validator = new Validator($schemaLoader);

// $path is also a relative url, e.g. /some/example/mainPath
$validator->validate($data, $path);

The custom resolver is working fine. I get the correct schema for the mainPath & also moving $ref to parent object works fine (jumps to https://github.com/opis/json-schema/blob/master/src/Parsers/SchemaParser.php#L490 correctly), for example:

{
    "type": "string",
    "format": "select",
    "enum": ["test1", "test2"],
    "$ref": "/some/example/subPath"
}

But I need it inside enum... May enum validation throws an error before resolving & replacing $ref property?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant