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

Stack level too deep #335

Open
mrtj opened this issue Mar 16, 2018 · 2 comments
Open

Stack level too deep #335

mrtj opened this issue Mar 16, 2018 · 2 comments

Comments

@mrtj
Copy link

mrtj commented Mar 16, 2018

I am working with a schema that has recursive references (eg. comments on comments) and the document generator fails with the following error:

/Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/schema.rb:103:in `merge': stack level too deep (SystemStackError)
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/schema.rb:103:in `each'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/schema.rb:103:in `inject'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/schema.rb:103:in `dereference'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/templates/schemata/helper.erb:86:in `block in extract_schemata_refs'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/templates/schemata/helper.erb:84:in `each'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/templates/schemata/helper.erb:84:in `extract_schemata_refs'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/templates/schemata/helper.erb:88:in `block in extract_schemata_refs'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/templates/schemata/helper.erb:84:in `each'
	 ... 9814 levels...
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/lib/prmd/cli.rb:95:in `run'
	from /Library/Ruby/Gems/2.3.0/gems/prmd-0.13.0/bin/prmd:6:in `<top (required)>'
	from /usr/local/bin/prmd:22:in `load'
	from /usr/local/bin/prmd:22:in `<main>'

Is there any support planned for recursive schemas?

@geemus
Copy link
Member

geemus commented Mar 16, 2018

It hadn't really come up yet, but perhaps there is no time like the present. Could you perhaps provide a bit more insight into what you are trying to do and a sample repro schema? Thanks!

@mrtj
Copy link
Author

mrtj commented Mar 16, 2018

I am trying to model a (subset) of Facebook Graph API, and for example for the entity "comment" I came up the following json schema (simplified here but stil reproduces the bug):

{
  "title": "Comment entity",
  "description": "This entity represents a comment.",
  "id": "http://schema.neosperience.com/facebook-services/comment",
  "type": "object",
  "definitions": {
    "identity": {
      "$ref": "/comment#/definitions/id"
    },
    "id": {
      "type": "string",
      "description": "The identifier of the comment."
    },
    "message": {
      "type": "string",
      "description": "The comment text."
    },
    "comments": {
      "description": "Comments made on this comment.",
      "type": "array",
      "items": {
        "$ref": "/comment"
      }
    }
  },
  "properties": {
    "id": {
      "$ref": "/comment#/definitions/id"
    },
    "comments": {
      "$ref": "/comment#/definitions/comments"
    },
    "message": {
      "$ref": "/comment#/definitions/message"
    }
  },
  "links": []
}

I guess the problem is the recursive / circular reference made from the comments field to the comment itself. However this is a valid json schema and it has practical use as well.

The combine and the verify commands pass, I get the error when trying to generate the documentation with

prmd doc generated/schema.json > generated/schema.md

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

2 participants