Skip to content

Commit

Permalink
ignore set explicit content type for multipart
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Sep 22, 2024
1 parent d8ca484 commit 9051093
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Generator/Client/Language/php-operation.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

$options = [
'headers' => [
{% if operation.bodyContentType %}
{% if operation.bodyContentShape == 'multipart/form-data' %}
{% elseif operation.bodyContentType %}
'Content-Type' => '{{ operation.bodyContentType }}',
{% elseif operation.bodyName %}
'Content-Type' => 'application/json'
Expand Down
3 changes: 2 additions & 1 deletion src/Generator/Client/Language/typescript-operation.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
url: url,
method: '{{ operation.method }}',
headers: {
{% if operation.bodyContentType %}
{% if operation.bodyContentShape == 'multipart/form-data' %}
{% elseif operation.bodyContentType %}
'Content-Type': '{{ operation.bodyContentType }}',
{% elseif operation.bodyName %}
'Content-Type': 'application/json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public function multipart(array $body): array

$options = [
'headers' => [
'Content-Type' => 'multipart/form-data',
],
'query' => $this->parser->query([
], [
Expand Down
1 change: 0 additions & 1 deletion tests/Generator/Client/resource/php_test/ProductTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ public function multipart(array $payload): TestResponse

$options = [
'headers' => [
'Content-Type' => 'multipart/form-data',
],
'query' => $this->parser->query([
], [
Expand Down
30 changes: 30 additions & 0 deletions tests/Generator/Client/resource/php_test/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
class TestResponse implements \JsonSerializable, \PSX\Record\RecordableInterface
{
protected ?TestMapScalar $args = null;
protected ?string $data = null;
protected ?TestMapScalar $files = null;
protected ?TestMapScalar $form = null;
protected ?TestMapScalar $headers = null;
protected ?TestRequest $json = null;
protected ?string $method = null;
Expand All @@ -21,6 +24,30 @@ public function getArgs() : ?TestMapScalar
{
return $this->args;
}
public function setData(?string $data) : void
{
$this->data = $data;
}
public function getData() : ?string
{
return $this->data;
}
public function setFiles(?TestMapScalar $files) : void
{
$this->files = $files;
}
public function getFiles() : ?TestMapScalar
{
return $this->files;
}
public function setForm(?TestMapScalar $form) : void
{
$this->form = $form;
}
public function getForm() : ?TestMapScalar
{
return $this->form;
}
public function setHeaders(?TestMapScalar $headers) : void
{
$this->headers = $headers;
Expand Down Expand Up @@ -50,6 +77,9 @@ public function toRecord() : \PSX\Record\RecordInterface
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('args', $this->args);
$record->put('data', $this->data);
$record->put('files', $this->files);
$record->put('form', $this->form);
$record->put('headers', $this->headers);
$record->put('json', $this->json);
$record->put('method', $this->method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ export class Client extends ClientAbstract {
url: url,
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
params: this.parser.query({
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ export class ProductTag extends TagAbstract {
url: url,
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
params: this.parser.query({
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {TestMapScalar} from "./TestMapScalar";
import {TestRequest} from "./TestRequest";
export interface TestResponse {
args?: TestMapScalar
data?: string
files?: TestMapScalar
form?: TestMapScalar
headers?: TestMapScalar
json?: TestRequest
method?: string
Expand Down

0 comments on commit 9051093

Please sign in to comment.