Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

issue resolving $ref: AttributeError: 'list' object has no attribute 'items' #54

Open
markfink opened this issue Aug 9, 2017 · 1 comment
Labels

Comments

@markfink
Copy link

markfink commented Aug 9, 2017

in my opinion swagger-parser is not handling $ref correctly (see trace at the bottom). I tried with both python2.7 and python3.6. This relates to validate_request - definitions_example works fine.

relevant part of my spec:

definitions:
  NotificationARNs:
    type: array
    items:
      type: string
      example: arn:aws:sns:eu-west-1:123456789012:mytopic1
  stack:
    type: object
    properties:
      StackName:
        type: string
        example: infra-dev-kumo-sample-stack
      RoleARN:
        type: string
        example: arn:aws:iam::<AccountID>:role/<CloudFormationRoleName>
      NotificationARNs:
        $ref: '#/definitions/NotificationARNs'

if I resolve the $ref manually it works fine:

definitions:
  #NotificationARNs:
  #  type: array
  #  items:
  #    type: string
  #    example: arn:aws:sns:eu-west-1:123456789012:mytopic1
  stack:
    type: object
    properties:
      StackName:
        type: string
        example: team-dev-my-application-stack
      RoleARN:
        type: string
        #$ref: '#/definitions/parameters'
        pattern: "arn:aws:([a-zA-Z0-9-])+:([a-z]{2}-[a-z]+-d{1})?:(d{12})?:(.*)"
        example: arn:aws:iam::<AccountID>:role/<CloudFormationRoleName>
      NotificationARNs:
        type: array
        items:
          type: string
          example: arn:aws:sns:eu-west-1:123456789012:mytopic1
        #$ref: '#/definitions/NotificationARNs'
Traceback (most recent call last):
  File "config_validate_kumo.py", line 37, in <module>
    parser.validate_request('/kumo', 'get', body=my_config)
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 713, in validate_request
    is_ok, msg = self._validate_body_parameters(body, action_spec)
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 793, in _validate_body_parameters
    if not self.validate_definition(definition_name, body):
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 508, in validate_definition
    if not self._validate_type(properties_dict[key], value):
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 526, in _validate_type
    return self.validate_definition(def_name, value)
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 508, in validate_definition
    if not self._validate_type(properties_dict[key], value):
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 526, in _validate_type
    return self.validate_definition(def_name, value)
  File "/Users/fin0007m/devel/gcdt/bvenv/lib/python2.7/site-packages/swagger_parser/swagger_parser.py", line 503, in validate_definition
    for key, value in dict_to_test.items():
AttributeError: 'list' object has no attribute 'items'
@markfink markfink changed the title issue validating arrays: AttributeError: 'list' object has no attribute 'items' issue resolving $ref: AttributeError: 'list' object has no attribute 'items' Aug 9, 2017
@cyprieng cyprieng added the bug label Sep 10, 2017
@cyprieng
Copy link
Owner

Thank you for reporting this issue ! I will try to fix this soon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants