Merge pull request #151 from yanoosh/accepts-header

Added consumes and produces to php templates.
This commit is contained in:
Tony Tam 2014-02-11 22:32:29 -08:00
commit 405e8b1786
3 changed files with 12 additions and 6 deletions

View File

@ -50,7 +50,6 @@ class APIClient {
$headerParams) {
$headers = array();
$headers[] = "Content-type: application/json";
# Allow API key from $headerParams to override default
$added_api_key = False;
@ -234,8 +233,3 @@ class APIClient {
return $instance;
}
}
?>

View File

@ -45,6 +45,8 @@ class {{classname}} {
$method = "{{httpMethod}}";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = '{{produces}}';
$headerParams['Content-Type'] = '{{consume}}';
{{#queryParams}}
if(${{paramName}} != null) {

View File

@ -384,6 +384,16 @@ class Codegen(config: CodegenConfig) {
"httpMethod" -> operation.method.toUpperCase,
"httpMethodLowerCase" -> operation.method.toLowerCase,
operation.method.toLowerCase -> "true")
if (0 < operation.consumes.length) {
properties += "consume" -> operation.consumes(0)
} else {
properties += "consume" -> "application/json"
}
if (0 < operation.produces.length) {
properties += "produces" -> operation.produces
} else {
properties += "produces" -> "application/json"
}
if (requiredParams.size > 0) properties += "requiredParamCount" -> requiredParams.size.toString
operation.responseClass.indexOf("[") match {
case -1 => {