[python] Triple quote strings with new lines in default values (#4941)

* Triple quote python strings in defaults

When the model contains a string with a default value with new lines in
it, simply quoting generates invalid python code. Using triple quotes
for all string defaults makes sure the generated code will be a valid
python string.

Fixes #4862

* Wrap default string in triple quotes when it contains new lines

* Add newly generated python sample files
This commit is contained in:
Jacobo de Vera
2017-03-07 07:46:38 +01:00
committed by wing328
parent 122194c30e
commit 7de1eeb987
3 changed files with 7 additions and 3 deletions

View File

@@ -116,7 +116,7 @@ class ApiClient(object):
collection_formats)
for k, v in path_params:
resource_path = resource_path.replace(
'{%s}' % k, quote(str(v), safe=""))
'{%s}' % k, quote(str(v), safe='')) # no safe chars, encode everything
# query parameters
if query_params: