Skip to content

Circular references #281

Closed
Closed
@nicolas-t

Description

@nicolas-t

Hi,

I'm using the v2.0.5, and I encouter this error:

PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 127

This error seems to be related to circular references.

Here is a minimal version of my 2 schemas:

Author.json _in some cases_ will return a collection of Posts

{
    "$schema": "http://json-schema.org/draft-04/schema",
    "id": "Author.json",
    "type": "object",
    "properties": {
        ...
        "posts": {
            "type": "array",
            "items": {
                "$ref": "Post.json#"
            }
        }
    }
}

Post.json _in some cases_ will return an Author

{
    "$schema": "http://json-schema.org/draft-04/schema",
    "id": "Post.json",
    "title": "Post Schema",
    "type": "object",
    "properties": {
        ...
        "author": {
            "$ref": "Author.json#"
        }
    }
}

I just have two cases:

  1. I want an author with a collection of posts
  2. I want a post with his author

The circular cases (where I want an author with his posts+author) never happens in real life.

Not sure if i'm clear.

My question:
Is it a problem of the way I designed my schemas or is it a problem of your validation library?

Best regards,

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