Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Preserve values from being formatted #420

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

Merged
n2ygk merged 1 commit into django-json-api:master from sliverc:recursive_format_keys
Jun 18, 2018

Conversation

Copy link
Member

@sliverc sliverc commented Apr 16, 2018
edited
Loading

Fixes #313

Description of the Change

According to Json API Spec should only field names (hence the name JSON_API_FORMAT_FIELD_NAMES) be specifically named resp. formatted. The value itself may contain any json value though and we should keep it as is.

With the option JSON_API_FORMAT_KEYS all keys (incl. value keys) are formatted though. This leads to underscored keys of a attribute value in Django code (or even on the database when using JSONField)

To fix this I have introduced JSON_API_FIELD_NAMES setting which preserves value from being formatted. JSON_API_FORMAT_KEYS still works as before though for backwards compatibility but is marked deprecated.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added (not needed as only build change)
  • documentation updated (not needed as only build change)
  • changelog entry added to CHANGELOG.md
  • author name in AUTHORS

@sliverc sliverc force-pushed the recursive_format_keys branch 3 times, most recently from 6131764 to 89d8445 Compare April 17, 2018 07:02
Copy link

codecov-io commented Apr 17, 2018
edited
Loading

Codecov Report

Merging #420 into master will increase coverage by 0.08%.
The diff coverage is 98.52%.

Impacted file tree graph

@@ Coverage Diff @@
## master #420 +/- ##
==========================================
+ Coverage 92.6% 92.68% +0.08% 
==========================================
 Files 54 54 
 Lines 2812 2858 +46 
==========================================
+ Hits 2604 2649 +45 
- Misses 208 209 +1
Impacted Files Coverage Δ
example/settings/dev.py 100% <100%> (ø) ⬆️
example/settings/test.py 100% <100%> (ø) ⬆️
rest_framework_json_api/parsers.py 97.14% <100%> (ø) ⬆️
rest_framework_json_api/renderers.py 85.32% <100%> (ø) ⬆️
example/tests/unit/test_renderers.py 100% <100%> (ø) ⬆️
example/tests/test_parsers.py 100% <100%> (ø) ⬆️
example/tests/test_generic_viewset.py 100% <100%> (ø) ⬆️
example/tests/test_model_viewsets.py 100% <100%> (ø) ⬆️
example/tests/unit/test_settings.py 100% <100%> (ø) ⬆️
example/api/resources/identity.py 94.28% <100%> (ø) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 028f191...3d7637b. Read the comment docs.

@sliverc sliverc force-pushed the recursive_format_keys branch from 89d8445 to a8bdf10 Compare June 14, 2018 09:56
Introduce `JSON_API_FORMAT_FIELD_NAMES` which preserves keys of values.
`JSON_API_FORMAT_KEYS` still exists but is deprecated.
@sliverc sliverc force-pushed the recursive_format_keys branch from a8bdf10 to 3d7637b Compare June 14, 2018 13:01
@sliverc sliverc requested a review from n2ygk June 14, 2018 13:06
Copy link
Contributor

@n2ygk n2ygk left a comment

Choose a reason for hiding this comment

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

Did the existing format_keys() also format the values? I was not aware, but I see where it recurses down the tree.

Good that you've fixed it.

@n2ygk n2ygk merged commit 79e7738 into django-json-api:master Jun 18, 2018
@sliverc sliverc deleted the recursive_format_keys branch June 18, 2018 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@n2ygk n2ygk n2ygk approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

All attribute value keys inflected with underscore in parser

AltStyle によって変換されたページ (->オリジナル) /