Add a mandatory 'id' attribute to 'resource' elements

This is now required by api-site.

Change-Id: Ifdfd80060cb294ded92c99743c371ae22df933b7
This commit is contained in:
Cyril Roelandt 2014-01-30 16:19:45 +01:00
parent 607177b8b4
commit 9caebf8371
1 changed files with 6 additions and 1 deletions

View File

@ -140,7 +140,12 @@ class MyNodeVisitor(SparseNodeVisitor):
def build_resources(root, d, path=''):
for k, v in d.iteritems():
tmp = ET.SubElement(root, 'resource', {'path': k})
tmp = ET.SubElement(root, 'resource', {
# NOTE(cyril): sometimes, id and path might differ. This
# should be good enough, though.
'id': k.replace('{', '').replace('}', ''),
'path': k,
})
if path + '/' + k + '/' in self.paths:
for method in self.paths[path + '/' + k + '/']:
ET.SubElement(tmp, 'method', {'href': '#' + method})