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

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

Description

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions