Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fixing sub fields on docs #367

Merged
merged 1 commit into from

2 participants

Matthew Francis-Landau Ben Mills
Ben Mills remear merged commit cb3a42b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2014
  1. Matthew Francis-Landau
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 17 deletions.
  1. +13 −17 balanced_docs/rev1_api_spec.py
30 balanced_docs/rev1_api_spec.py
View
@@ -70,14 +70,6 @@ def match_form(self, name):
'holds': 'card_holds'
}.get(resource, resource)
- # if resource == 'card_holds': # and action == 'update':
- # # TODO asdfasdf, gaaaa
- # return self.dockers.match_form('holds.' + action)
- # if resource == 'credits':
- # return self.dockers.match_form(name)
-
- # action is currently create or update
- #method = 'POST' if action == 'create' else 'PUT'
if action == 'create':
reqs = self['resources_create'][resource]
else:
@@ -107,14 +99,14 @@ def get_description(view, name):
if description is None:
try:
- description = view['properties'].get('links', {}).get(name, {}).get('description')
+ description = (
+ view['properties']
+ .get('links', {}).get('properties', {})
+ .get(name, {}).get('description')
+ )
except:
description = None
- if description is None:
- if 'description' in view:
- description = view['description']
-
return description
def get_type(name):
@@ -132,7 +124,7 @@ def generate_form(resource, action):
for name in all_keys:
field = {}
ignored_object_keys = ['links']
- if get_type(name) == 'object' and name not in ignored_object_keys:
+ if get_type(name) == 'object':# and name not in ignored_object_keys:
resource_model = self._find_file('_models/{}.json'.format(name))
subkeys = set()
subfields = []
@@ -144,9 +136,13 @@ def generate_form(resource, action):
subkeys.add(key)
for sk in subkeys:
+ descr = get_description(resource_model, sk)
+ if not descr:
+ continue
+
subfield = {
'name': sk,
- 'description': get_description(resource_model, sk),
+ 'description': descr,
'nullable': sk in nullable,
'required': sk in required,
'tags': [],
@@ -166,7 +162,7 @@ def generate_form(resource, action):
'nullable': name in nullable,
'required': name in required,
'validate': None,
- 'type': 'form_field',
+ 'type': 'form_field' if subfields else 'object',
'description': get_description(view, name),
'name': name
}
@@ -188,4 +184,4 @@ def generate_form(resource, action):
'name': '{}_{}_form'.format(resource, action)
}
- return generate_form(resource, action)
+ return generate_form(resource, action)
Something went wrong with that request. Please try again.