forked from loafle/openapi-generator-original
[php] 2.3 - fix form params json encoding (#5701)
* fixed tests expectations not compatible with phpunit 4 * added test and endpoint definition, updated template * regenerated sample * regenerated security sample
This commit is contained in:
@@ -222,6 +222,17 @@ use {{invokerPackage}}\ObjectSerializer;
|
||||
}
|
||||
{{/bodyParams}}
|
||||
|
||||
if ($multipart) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}],
|
||||
[{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
@@ -237,22 +248,14 @@ use {{invokerPackage}}\ObjectSerializer;
|
||||
}
|
||||
$httpBody = new MultipartStream($multipartContents); // for HTTP post (form)
|
||||
|
||||
} elseif ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = \GuzzleHttp\json_encode($formParams);
|
||||
|
||||
} else {
|
||||
$httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form)
|
||||
}
|
||||
}
|
||||
|
||||
if ($httpBody instanceof MultipartStream) {
|
||||
$headers= $this->headerSelector->selectHeadersForMultipart(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}],
|
||||
[{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||
);
|
||||
}
|
||||
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
// this endpoint requires API key authentication
|
||||
|
||||
@@ -872,6 +872,29 @@ paths:
|
||||
description: Output composite
|
||||
schema:
|
||||
$ref: '#/definitions/OuterComposite'
|
||||
/fake/jsonFormData:
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
summary: test json serialization of form data
|
||||
description: ''
|
||||
operationId: testJsonFormData
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- name: param
|
||||
in: formData
|
||||
description: field1
|
||||
required: true
|
||||
type: string
|
||||
- name: param2
|
||||
in: formData
|
||||
description: field2
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
securityDefinitions:
|
||||
petstore_auth:
|
||||
type: oauth2
|
||||
|
||||
Reference in New Issue
Block a user