Skip to content

Commit

Permalink
set accept header of content type is available
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Feb 22, 2025
1 parent 672bdfd commit df51338
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Generator/Client/Language/php-operation.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
'Content-Type' => '{{ operation.bodyContentType }}',
{% elseif operation.bodyName %}
'Content-Type' => 'application/json',
{% endif %}
{% if operation.return.contentType %}
'Accept' => '{{ operation.return.contentType }}',
{% endif %}
],
'query' => $this->parser->query([
Expand Down
3 changes: 3 additions & 0 deletions src/Generator/Client/Language/typescript-operation.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
'Content-Type': '{{ operation.bodyContentType }}',
{% elseif operation.bodyName %}
'Content-Type': 'application/json',
{% endif %}
{% if operation.return.contentType %}
'Accept': '{{ operation.return.contentType }}',
{% endif %}
},
params: this.parser.query({
Expand Down
6 changes: 6 additions & 0 deletions tests/Generator/Client/resource/php_content_type/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function binary(\Psr\Http\Message\StreamInterface $body): \Psr\Http\Messa
$options = [
'headers' => [
'Content-Type' => 'application/octet-stream',
'Accept' => 'application/octet-stream',
],
'query' => $this->parser->query([
], [
Expand Down Expand Up @@ -77,6 +78,7 @@ public function form(array $body): array
$options = [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => 'application/x-www-form-urlencoded',
],
'query' => $this->parser->query([
], [
Expand Down Expand Up @@ -125,6 +127,7 @@ public function json(mixed $body): mixed
$options = [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'query' => $this->parser->query([
], [
Expand Down Expand Up @@ -170,6 +173,7 @@ public function multipart(\Sdkgen\Client\Multipart $body): \Sdkgen\Client\Multip

$options = [
'headers' => [
'Accept' => 'multipart/form-data',
],
'query' => $this->parser->query([
], [
Expand Down Expand Up @@ -218,6 +222,7 @@ public function text(string $body): string
$options = [
'headers' => [
'Content-Type' => 'text/plain',
'Accept' => 'text/plain',
],
'query' => $this->parser->query([
], [
Expand Down Expand Up @@ -264,6 +269,7 @@ public function xml(string $body): string
$options = [
'headers' => [
'Content-Type' => 'application/xml',
'Accept' => 'application/xml',
],
'query' => $this->parser->query([
], [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class Client extends ClientAbstract {
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream',
'Accept': 'application/octet-stream',
},
params: this.parser.query({
}, [
Expand Down Expand Up @@ -62,6 +63,7 @@ export class Client extends ClientAbstract {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/x-www-form-urlencoded',
},
params: this.parser.query({
}, [
Expand Down Expand Up @@ -95,6 +97,7 @@ export class Client extends ClientAbstract {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
params: this.parser.query({
}, [
Expand Down Expand Up @@ -127,6 +130,7 @@ export class Client extends ClientAbstract {
url: url,
method: 'POST',
headers: {
'Accept': 'multipart/form-data',
},
params: this.parser.query({
}, [
Expand Down Expand Up @@ -160,6 +164,7 @@ export class Client extends ClientAbstract {
method: 'POST',
headers: {
'Content-Type': 'text/plain',
'Accept': 'text/plain',
},
params: this.parser.query({
}, [
Expand Down Expand Up @@ -193,6 +198,7 @@ export class Client extends ClientAbstract {
method: 'POST',
headers: {
'Content-Type': 'application/xml',
'Accept': 'application/xml',
},
params: this.parser.query({
}, [
Expand Down

0 comments on commit df51338

Please sign in to comment.