Fix content-type and accept in PHP API

This commit is contained in:
William Cheng
2015-04-01 04:26:32 +08:00
parent 6ac497d774
commit 03c48af9e6
9 changed files with 397 additions and 42 deletions

View File

@@ -44,8 +44,12 @@ class {{classname}} {
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
$_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}';
if ($_header_accept !== '') {
$headerParams['Accept'] = $_header_accept;
}
$_header_content_type = array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}});
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
{{#queryParams}}// query params
if(${{paramName}} !== null) {