Skip to content

Make python name to JSON name attribute mapping via attribute_map optional. #58

@milancermak

Description

@milancermak

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Expected Behavior

When serializing, use the python attribute name if not present in attribute_map.

Current Behavior

If a name of a python attribute is the same as its name in the serialized object, it still needs to be present in the attribute_map.

Possible Solution

// Not required, but suggest a fix/reason for the bug,
// or ideas how to implement the addition or change

I guess it's a one-line change in the Serializer? Sorry, didn't dig into it too much.

Steps to Reproduce (for bugs)

// Provide a self-contained, concise snippet of code
// For more complex issues provide a repo with the smallest sample that reproduces the bug
// Including business logic or unrelated code makes diagnosis more difficult
@attr.s
class Skill:
    launch_count = attr.ib()

    deserialized_type = {'launch_count': 'int'}
    attribute_map = {'launch_count': 'launch_count'} # needless
    # snip

Context

I'm using the DefaultSerializer to serialize my models for DynamoDB. It's really cool. I want to suggest of using the python's attribute name as the name of the value in the serialized object if it is not present in the attribute_map mapping. In the example posted above, the attribute_map could be removed altogether, a pattern in a lot of my models. This direct mapping is also quite common in the SDK models, for example here in SimpleCard

Your Environment

  • ASK SDK for Python used: 1.5.0
  • Operating System and version: OS X

Python version info

  • Python version used for development: 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions