Fix curl sample generation in the documentation

This commit is contained in:
Julien Duponchelle committed 2015-02-27 18:47:08 +01:00
1 parent ebd72d1149
commit d0c386860e
83 files changed
+182 -183

No files matched your search

+3 -3
View File
@@ -93,14 +93,14 @@ class Query:
response.json = {}
response.html = ""
if kwargs.get('example') and os.environ.get("PYTEST_BUILD_DOCUMENTATION") == "1":
self._dump_example(method, response.route, body, response)
self._dump_example(method, response.route, path, body, response)
return response
def _dump_example(self, method, path, body, response):
def _dump_example(self, method, route, path, body, response):
"""Dump the request for the documentation"""
if path is None:
return
with open(self._example_file_path(method, path), 'w+') as f:
with open(self._example_file_path(method, route), 'w+') as f:
f.write("curl -i -X {} 'http://localhost:8000{}'".format(method, path))
if body:
f.write(" -d '{}'".format(re.sub(r"\n", "", json.dumps(json.loads(body), sort_keys=True))))