diff --git a/src/Generator/Client/Language/php-operation.php.twig b/src/Generator/Client/Language/php-operation.php.twig index 033bd12..cbb9931 100644 --- a/src/Generator/Client/Language/php-operation.php.twig +++ b/src/Generator/Client/Language/php-operation.php.twig @@ -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' diff --git a/src/Generator/Client/Language/typescript-operation.ts.twig b/src/Generator/Client/Language/typescript-operation.ts.twig index 81ea649..90f23c2 100644 --- a/src/Generator/Client/Language/typescript-operation.ts.twig +++ b/src/Generator/Client/Language/typescript-operation.ts.twig @@ -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', diff --git a/tests/Generator/Client/resource/php_content_type/Client.php b/tests/Generator/Client/resource/php_content_type/Client.php index a1e0ef9..02f3135 100644 --- a/tests/Generator/Client/resource/php_content_type/Client.php +++ b/tests/Generator/Client/resource/php_content_type/Client.php @@ -170,7 +170,6 @@ public function multipart(array $body): array $options = [ 'headers' => [ - 'Content-Type' => 'multipart/form-data', ], 'query' => $this->parser->query([ ], [ diff --git a/tests/Generator/Client/resource/php_test/ProductTag.php b/tests/Generator/Client/resource/php_test/ProductTag.php index 8586f51..3ab4cc7 100644 --- a/tests/Generator/Client/resource/php_test/ProductTag.php +++ b/tests/Generator/Client/resource/php_test/ProductTag.php @@ -362,7 +362,6 @@ public function multipart(array $payload): TestResponse $options = [ 'headers' => [ - 'Content-Type' => 'multipart/form-data', ], 'query' => $this->parser->query([ ], [ diff --git a/tests/Generator/Client/resource/php_test/TestResponse.php b/tests/Generator/Client/resource/php_test/TestResponse.php index 2fa349b..76afaa5 100644 --- a/tests/Generator/Client/resource/php_test/TestResponse.php +++ b/tests/Generator/Client/resource/php_test/TestResponse.php @@ -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; @@ -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; @@ -50,6 +77,9 @@ public function toRecord() : \PSX\Record\RecordInterface /** @var \PSX\Record\Record $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); diff --git a/tests/Generator/Client/resource/typescript_content_type/Client.ts b/tests/Generator/Client/resource/typescript_content_type/Client.ts index aebd6e8..1e68e09 100644 --- a/tests/Generator/Client/resource/typescript_content_type/Client.ts +++ b/tests/Generator/Client/resource/typescript_content_type/Client.ts @@ -154,7 +154,6 @@ export class Client extends ClientAbstract { url: url, method: 'POST', headers: { - 'Content-Type': 'multipart/form-data', }, params: this.parser.query({ }, [ diff --git a/tests/Generator/Client/resource/typescript_test/ProductTag.ts b/tests/Generator/Client/resource/typescript_test/ProductTag.ts index 84dfae3..c657309 100644 --- a/tests/Generator/Client/resource/typescript_test/ProductTag.ts +++ b/tests/Generator/Client/resource/typescript_test/ProductTag.ts @@ -331,7 +331,6 @@ export class ProductTag extends TagAbstract { url: url, method: 'POST', headers: { - 'Content-Type': 'multipart/form-data', }, params: this.parser.query({ }, [ diff --git a/tests/Generator/Client/resource/typescript_test/TestResponse.ts b/tests/Generator/Client/resource/typescript_test/TestResponse.ts index 62e0f55..f560e24 100644 --- a/tests/Generator/Client/resource/typescript_test/TestResponse.ts +++ b/tests/Generator/Client/resource/typescript_test/TestResponse.ts @@ -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