Skip to content

deserializer with camel_case_convert option requires _additionalProperties #95

Closed
@alex-vayu

Description

@alex-vayu
from typedpy import ImmutableStructure, String, Deserializer


class PairOne(ImmutableStructure):
    the_name: String
    the_value: String
    _additionalProperties = False


class PairTwo(ImmutableStructure):
    the_name: String
    the_value: String


data: dict = {"theName": "name", "theValue": "value"}

p1 = Deserializer(PairOne, camel_case_convert=True).deserialize(data)
p2 = Deserializer(PairTwo, camel_case_convert=True).deserialize(data)

assert p1 == p2
Traceback (most recent call last):
  File "/Users/alex.benenson/Library/Application Support/JetBrains/PyCharm2021.2/scratches/scratch.py", line 18, in <module>
    p2 = Deserializer(PairTwo, camel_case_convert=True).deserialize(data)
  File "/Users/alex.benenson/Library/Caches/pypoetry/virtualenvs/services-pHQVF7vU-py3.9/lib/python3.9/site-packages/typedpy/serialization_wrappers.py", line 76, in deserialize
    return deserialize_structure(
  File "/Users/alex.benenson/Library/Caches/pypoetry/virtualenvs/services-pHQVF7vU-py3.9/lib/python3.9/site-packages/typedpy/serialization.py", line 575, in deserialize_structure
    return deserialize_structure_internal(
  File "/Users/alex.benenson/Library/Caches/pypoetry/virtualenvs/services-pHQVF7vU-py3.9/lib/python3.9/site-packages/typedpy/serialization.py", line 501, in deserialize_structure_internal
    if (camel_case_convert or isinstance(mapper, mappers)) and not getattr(
AttributeError: type object 'PairTwo' has no attribute '_additionalProperties'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions