Use doc strings for resource and method docs. Tweak some docs. Switch to 100 length lines.

This commit is contained in:
jakedt 2014-03-11 15:20:03 -04:00
parent 978d68f0e0
commit 220649e579
3 changed files with 43 additions and 51 deletions

View file

@ -29,11 +29,12 @@ def swagger_route_data():
endpoint_method = app.view_functions[rule.endpoint]
if 'view_class' in dir(endpoint_method):
view_class = endpoint_method.view_class
operations = []
method_names = list(rule.methods.difference(['HEAD', 'OPTIONS']))
for method_name in method_names:
method = getattr(endpoint_method.view_class, method_name.lower(), None)
method = getattr(view_class, method_name.lower(), None)
parameters = []
for param in rule.arguments:
@ -49,16 +50,15 @@ def swagger_route_data():
if req_schema_name:
parameters.append({
'paramType': 'body',
'name': 'request_body',
'name': 'body',
'description': 'Request body contents.',
'dataType': req_schema_name,
'required': True,
})
schema = endpoint_method.view_class.schemas[req_schema_name]
schema = view_class.schemas[req_schema_name]
models[req_schema_name] = schema
logger.debug('method dir: %s', dir(method))
if '__api_query_params' in dir(method):
for param_spec in method.__api_query_params:
new_param = {
@ -79,13 +79,14 @@ def swagger_route_data():
'method': method_name,
'nickname': method_metadata(method, 'nickname'),
'type': 'void',
'summary': method.__doc__ if method.__doc__ else '',
'parameters': parameters,
})
swagger_path = PARAM_REGEX.sub(r'{\2}', rule.rule)
apis.append({
'path': swagger_path,
'description': 'Resource description.',
'description': view_class.__doc__ if view_class.__doc__ else "",
'operations': operations,
})
@ -96,10 +97,9 @@ def swagger_route_data():
'resourcePath': '/',
'info': {
'title': 'Quay.io API',
'description': ('This API allows you to perform many of the operations '
'required to work with Quay.io repositories, users, and '
'organizations. You can find out more at '
'<a href="https://quay.io">Quay.io</a>.'),
'description': ('This API allows you to perform many of the operations required to work '
'with Quay.io repositories, users, and organizations. You can find out more '
'at <a href="https://quay.io">Quay.io</a>.'),
'termsOfServiceUrl': 'https://quay.io/tos',
'contact': 'support@quay.io',
},
@ -110,6 +110,8 @@ def swagger_route_data():
@resource('/v1/discovery')
class DiscoveryResource(Resource):
"""Ability to inspect the API for usage information and documentation."""
@nickname('discovery')
def get(self):
""" List all of the API endpoints available in the swagger API format."""
return swagger_route_data()