Raise warning if top-level value is not a dict
Given the following 'parameters.yaml' file: resources_query_granular: type: string in: query required: false description: | Some description here... min_version: 1.22 Clearly 'min_version' is indented at the wrong level. However, the error message is pretty much useless: Exception occurred: File "./os_api_ref/__init__.py", line 261, in _check_yaml_sorting if value['in'] not in sections: TypeError: string indices must be integers, not str It's obvious we should be saying _what_ is causing this issue. Start doing this by way of an exception. Change-Id: If68f82de1e3bf37b1ab89f12adf78e0d8d123674
This commit is contained in:
parent
6483fe226a
commit
982382a549
|
@ -257,6 +257,11 @@ class RestParametersDirective(Table):
|
|||
|
||||
last = None
|
||||
for key, value in yaml_data.items():
|
||||
if not isinstance(value, dict):
|
||||
raise Exception('Expected a dict for {0}; got {0}={1}).\n'
|
||||
'You probably have indentation typo in your'
|
||||
'YAML source'.format(key, value))
|
||||
|
||||
# use of an invalid 'in' value
|
||||
if value['in'] not in sections:
|
||||
self.app.warn(
|
||||
|
|
Loading…
Reference in New Issue