|
@@ -101,13 +101,27 @@ class PostmanCollectionWriter
|
|
|
|
|
|
protected function generateEndpointItem(OutputEndpointData $endpoint): array
|
|
|
{
|
|
|
+ $method = $endpoint->httpMethods[0];
|
|
|
+
|
|
|
+ $bodyParameters = empty($endpoint->bodyParameters) ? null : $this->getBodyData($endpoint);
|
|
|
+
|
|
|
+ if ((in_array('PUT', $endpoint->httpMethods) || in_array('PATCH', $endpoint->httpMethods))
|
|
|
+ && isset($bodyParameters['formdata'])) {
|
|
|
+ $method = 'POST';
|
|
|
+ $bodyParameters['formdata'][] = [
|
|
|
+ 'key' => '_method',
|
|
|
+ 'value' => $endpoint->httpMethods[0],
|
|
|
+ 'type' => 'text',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
$endpointItem = [
|
|
|
'name' => $endpoint->metadata->title !== '' ? $endpoint->metadata->title : $endpoint->uri,
|
|
|
'request' => [
|
|
|
'url' => $this->generateUrlObject($endpoint),
|
|
|
- 'method' => $endpoint->httpMethods[0],
|
|
|
+ 'method' => $method,
|
|
|
'header' => $this->resolveHeadersForEndpoint($endpoint),
|
|
|
- 'body' => empty($endpoint->bodyParameters) ? null : $this->getBodyData($endpoint),
|
|
|
+ 'body' => $bodyParameters,
|
|
|
'description' => $endpoint->metadata->description,
|
|
|
],
|
|
|
'response' => $this->getResponses($endpoint),
|
|
@@ -129,6 +143,9 @@ class PostmanCollectionWriter
|
|
|
case 'multipart/form-data':
|
|
|
$inputMode = 'formdata';
|
|
|
break;
|
|
|
+ case 'application/x-www-form-urlencoded':
|
|
|
+ $inputMode = 'urlencoded';
|
|
|
+ break;
|
|
|
case 'application/json':
|
|
|
default:
|
|
|
$inputMode = 'raw';
|
|
@@ -138,6 +155,7 @@ class PostmanCollectionWriter
|
|
|
|
|
|
switch ($inputMode) {
|
|
|
case 'formdata':
|
|
|
+ case 'urlencoded':
|
|
|
$body[$inputMode] = $this->getFormDataParams($endpoint->cleanBodyParameters);
|
|
|
foreach ($endpoint->fileParameters as $key => $value) {
|
|
|
while (is_array($value)) {
|