mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
Merge pull request #151 from yanoosh/accepts-header
Added consumes and produces to php templates.
This commit is contained in:
commit
405e8b1786
@ -50,7 +50,6 @@ class APIClient {
|
|||||||
$headerParams) {
|
$headerParams) {
|
||||||
|
|
||||||
$headers = array();
|
$headers = array();
|
||||||
$headers[] = "Content-type: application/json";
|
|
||||||
|
|
||||||
# Allow API key from $headerParams to override default
|
# Allow API key from $headerParams to override default
|
||||||
$added_api_key = False;
|
$added_api_key = False;
|
||||||
@ -234,8 +233,3 @@ class APIClient {
|
|||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ class {{classname}} {
|
|||||||
$method = "{{httpMethod}}";
|
$method = "{{httpMethod}}";
|
||||||
$queryParams = array();
|
$queryParams = array();
|
||||||
$headerParams = array();
|
$headerParams = array();
|
||||||
|
$headerParams['Accept'] = '{{produces}}';
|
||||||
|
$headerParams['Content-Type'] = '{{consume}}';
|
||||||
|
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
if(${{paramName}} != null) {
|
if(${{paramName}} != null) {
|
||||||
|
@ -384,6 +384,16 @@ class Codegen(config: CodegenConfig) {
|
|||||||
"httpMethod" -> operation.method.toUpperCase,
|
"httpMethod" -> operation.method.toUpperCase,
|
||||||
"httpMethodLowerCase" -> operation.method.toLowerCase,
|
"httpMethodLowerCase" -> operation.method.toLowerCase,
|
||||||
operation.method.toLowerCase -> "true")
|
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
|
if (requiredParams.size > 0) properties += "requiredParamCount" -> requiredParams.size.toString
|
||||||
operation.responseClass.indexOf("[") match {
|
operation.responseClass.indexOf("[") match {
|
||||||
case -1 => {
|
case -1 => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user