Skip to content

Add failing test for lists as additional properties #429

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
merged 2 commits into from
Oct 5, 2022
Merged

Add failing test for lists as additional properties #429

merged 2 commits into from
Oct 5, 2022

Conversation

jyggen
Copy link
Contributor

@jyggen jyggen commented Oct 4, 2022

Upgrading from 0.15.0 to 0.16.0 introduces the following crash when a list is sent as an "additional property" (aka. not part of the OpenAPI spec):

self = <jsonschema_spec.accessors.SpecAccessor object at 0x1030d12d0>, content = {}, parts_deque = deque([])

    def _open(
        self, content: Mapping[Hashable, Any], parts_deque: Deque[Hashable]
    ) -> Any:
        if is_ref(content):
            ref = content["$ref"]
            with self.resolver.resolving(ref) as resolved:
                return self._open(resolved, parts_deque)

        try:
            part = parts_deque.popleft()
        except IndexError:
            return content
        else:
>           target = content[part]
E           KeyError: 'items'

content    = {}
part       = 'items'
parts_deque = deque([])
self       = <jsonschema_spec.accessors.SpecAccessor object at 0x1030d12d0>

This MR adds a test with a very basic case that reproduces it.

@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Merging #429 (9c3e430) into master (0567647) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #429   +/-   ##
=======================================
  Coverage   92.62%   92.62%           
=======================================
  Files         100      100           
  Lines        2414     2415    +1     
  Branches      304      304           
=======================================
+ Hits         2236     2237    +1     
  Misses        134      134           
  Partials       44       44           
Impacted Files Coverage Δ
...penapi_core/unmarshalling/schemas/unmarshallers.py 88.88% <100.00%> (+0.04%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@p1c2u p1c2u merged commit ac64879 into python-openapi:master Oct 5, 2022
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.

2 participants