jdiegodcp / ramlfications

Python parser for RAML
https://ramlfications.readthedocs.org
Apache License 2.0
234 stars 50 forks source link

validation fails if securityScheme doesn't contain 'settings' #118

Open bensonrodney opened 7 years ago

bensonrodney commented 7 years ago

validation fails if a securityScheme doesn't contain 'settings' but the spec defines it as optional.

https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md#settings

This spec is for version 0.8, it is the same in version 1.0

RochesterinNYC commented 7 years ago

Validation is failing for me on all the .raml setups I'm trying to validate that include securitySchemes.

Example .raml from raml-spec docs:

#%RAML 1.0
title: My Sample API
securitySchemes:
  oauth_1_0:
    description: |
      OAuth 1.0 continues to be supported for all API requests, but OAuth 2.0 is now preferred.
    type: OAuth 1.0
    settings:
      requestTokenUri: https://api.mysampleapi.com/1/oauth/request_token
      authorizationUri: https://api.mysampleapi.com/1/oauth/authorize
      tokenCredentialsUri: https://api.mysampleapi.com/1/oauth/access_token
      signatures: [ 'HMAC-SHA1', 'PLAINTEXT' ]

Fails with the following error:

$ ramlfications validate test.raml
Traceback (most recent call last):
  File "/Users/jameswen/.local/bin/ramlfications", line 11, in <module>
    sys.exit(main())
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/ramlfications/__main__.py", line 30, in validate
    vvalidate(ramlfile, config)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/ramlfications/__init__.py", line 98, in validate
    parse_raml(loader, config)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/ramlfications/parser.py", line 52, in parse_raml
    root.security_schemes = create_sec_schemes(root.raml_obj, root)
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/ramlfications/parser.py", line 282, in create_sec_schemes
    name = list(iterkeys(s))[0]
  File "/Users/jameswen/.local/venvs/ramlfications/lib/python2.7/site-packages/six.py", line 593, in iterkeys
    return d.iterkeys(**kw)
AttributeError: 'str' object has no attribute 'iterkeys'