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

Add allow_wildcard configuration #2362

Open
wants to merge 3 commits into
base: 0-10-stable
Choose a base branch
from

Conversation

Borzik
Copy link

@Borzik Borzik commented Oct 25, 2019

Purpose

jsonapi-renderer provides an allow_wildcard configuration which can be used to configure how * and ** include directives are treated. Since these wildcards are specific to AMS, in some cases it might be better to completely disable them instead of calling gsub(/\*/, '') on every include parameter passed to the API.

Changes

This PR adds a way to disable these wildcards by updating how JSONAPI::IncludeDirective is initialized. Default behaviour remains the same. When config.allow_wildcard is false, wildcards will be ignored by jsonapi-renderer.

Caveats

default_includes configuration, which is currently *, will not be respected and will be handled as if it was an empty string


def test_render_resource_with_deep_wildcard_include
assert_raise SystemStackError do
get :render_resource_with_deep_wildcard_include
Copy link
Author

@Borzik Borzik Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

** wildcard would cause stack overflow in this case. I guess this test can be removed, but left it here as a PoC for now.
Edit: It looks like it fails tests on jruby, so I removed it.

@Borzik Borzik marked this pull request as ready for review October 25, 2019 12:26
@Borzik Borzik requested a review from bf4 November 22, 2019 14:39
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

Successfully merging this pull request may close these issues.

None yet

2 participants