-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply key transforms to keys referenced in values
- Loading branch information
Showing
30 changed files
with
580 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[Back to Guides](../README.md) | ||
|
||
# Key Transforms | ||
|
||
Key Transforms modify the casing of keys and keys referenced in values in | ||
serialized responses. | ||
|
||
Provided key transforms: | ||
|
||
| Option | Result | | ||
|----|----| | ||
| `:camel` | ExampleKey | | ||
| `:camel_lower` | exampleKey | | ||
| `:dash` | example-key | | ||
| `:unaltered` | the original, unaltered key | | ||
| `:underscore` | example_key | | ||
| `nil` | use the adapter default | | ||
|
||
Key translation precedence is as follows: | ||
|
||
##### Adapter option | ||
|
||
`key_transform` is provided as an option via render. | ||
|
||
```render json: posts, each_serializer: PostSerializer, key_transform: :camel_lower``` | ||
|
||
##### Configuration option | ||
|
||
`key_transform` is set in `ActiveModelSerializers.config.key_transform`. | ||
|
||
```ActiveModelSerializers.config.key_transform = :camel_lower``` | ||
|
||
##### Adapter default | ||
|
||
Each adapter has a default transform configured: | ||
|
||
| Adapter | Default Key Transform | | ||
|----|----| | ||
| `Json` | `:unaltered` | | ||
| `JsonApi` | `:dash` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.