diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-19 19:23:10 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-19 19:23:10 +0900 |
commit | 55e0375851c439c97fc353c61d7c8b2b19485082 (patch) | |
tree | ae87f5a06cac202a3ed25afd9e8a433921c2f26a /jobs/{{base}}.cpp.mustache | |
parent | 878248db6122952998b390cf8ff4591c3f144474 (diff) | |
download | libquotient-55e0375851c439c97fc353c61d7c8b2b19485082.tar.gz libquotient-55e0375851c439c97fc353c61d7c8b2b19485082.zip |
Generated jobs: Don't dump empty strings to body parameters
This is important for (soon to be added) LoginJob, since the server is
sensitive to getting an (even empty) entity for "medium" as opposed to
omitting it entirely. This cannot be addressed on the spec level; on the
other hand, removing empty parameters from the payload reduces useless
bytes getting on the wire.
Diffstat (limited to 'jobs/{{base}}.cpp.mustache')
-rw-r--r-- | jobs/{{base}}.cpp.mustache | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/jobs/{{base}}.cpp.mustache b/jobs/{{base}}.cpp.mustache index 45668d4c..f3a6dc59 100644 --- a/jobs/{{base}}.cpp.mustache +++ b/jobs/{{base}}.cpp.mustache @@ -39,13 +39,14 @@ class {{camelCaseOperationId}}Job::Private Query {{^queryParams}}{ }{{/queryParams}}{{#queryParams?}}{ {{#queryParams}}{ "{{baseName}}", toJson({{paramName}}).toString() }{{#hasMore}}, {{/hasMore}}{{/queryParams}} - }{{/queryParams?}}, - Data {{^bodyParams}}{ }{{/bodyParams}}{{#bodyParams?}}{ - {{#bodyParams}}{ "{{baseName}}", toJson({{paramName}}) }{{#hasMore}}, - {{/hasMore}}{{/bodyParams}} - }{{/bodyParams?}}{{#skipAuth}}, false{{/skipAuth}} + }{{/queryParams?}}{{#skipAuth}}, Data { }, false{{/skipAuth}} ){{#responses}}{{#normalResponse?}}{{#properties?}}, d(new Private){{/properties?}}{{/normalResponse?}}{{/responses}} -{ } +{{#bodyParams?}}{ + Data _data;{{#bodyParams}} +{{^required?}}{{#string?}} if (!{{paramName}}.isEmpty()) + {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}} + setRequestData(_data); +}{{/bodyParams?}}{{^bodyParams?}}{ }{{/bodyParams?}} {{# responses}}{{#normalResponse?}}{{#properties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() { |