Skip to content

Commit

Permalink
Add an accept header in JSON request to help 3rd party services like …
Browse files Browse the repository at this point in the history
…localstack (#1721)
  • Loading branch information
jderusse committed Jun 5, 2024
1 parent ced8c1b commit 7236ddb
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## NOT RELEASED

### Changed

- Add `Accept: application/json` header in request to fix incompatibility with 3rd party providers

## 2.1.0

### Added
Expand Down
5 changes: 4 additions & 1 deletion src/Input/CreateResolverRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ public function getTypeName(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/DeleteResolverRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public function getTypeName(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/GetSchemaCreationStatusRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public function getApiId(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/ListApiKeysRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ public function getNextToken(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/ListResolversRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public function getTypeName(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/StartSchemaCreationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public function getDefinition(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/UpdateApiKeyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public function getId(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/UpdateDataSourceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ public function getType(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/UpdateResolverRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ public function getTypeName(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];

// Prepare query
$query = [];
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Input/CreateResolverRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function testRequest(): void
$expected = '
POST /v1/apis/apiId/types/foo/resolvers HTTP/1.1 200
Content-type: application/json
Accept: application/json
{
"cachingConfig": {
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/DeleteResolverRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/appsync/latest/APIReference/API_DeleteResolver.html
$expected = '
DELETE /v1/apis/api123/types/type/resolvers/field HTTP/1.1
Content-Type: application/json
Content-type: application/json
Accept: application/json
';

self::assertRequestEqualsHttpRequest($expected, $input->request());
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/GetSchemaCreationStatusRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/appsync/latest/APIReference/API_GetSchemaCreationStatus.html
$expected = '
GET /v1/apis/api123/schemacreation HTTP/1.1
Content-Type: application/json
Content-type: application/json
Accept: application/json
';

self::assertRequestEqualsHttpRequest($expected, $input->request());
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/ListApiKeysRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/appsync/latest/APIReference/API_ListApiKeys.html
$expected = '
GET /v1/apis/api123/apikeys?maxResults=1337&nextToken=token HTTP/1.1
Content-Type: application/json
Content-type: application/json
Accept: application/json
';

self::assertRequestEqualsHttpRequest($expected, $input->request());
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/ListResolversRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/appsync/latest/APIReference/API_ListResolvers.html
$expected = '
GET /v1/apis/api123/types/type/resolvers?maxResults=1337&nextToken=token HTTP/1.1
Content-Type: application/json
Content-type: application/json
Accept: application/json
';

self::assertRequestEqualsHttpRequest($expected, $input->request());
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Input/StartSchemaCreationRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function testRequest(): void
$expected = '
POST /v1/apis/api123/schemacreation HTTP/1.1
Content-type: application/json
Accept: application/json
{
"definition": "c2NoZW1hRGVmaW5pdGlvbg=="
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Input/UpdateApiKeyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function testRequest(): void
$expected = '
POST /v1/apis/api123/apikeys/keyId HTTP/1.1
Content-type: application/json
Accept: application/json
{
"description": "Description here",
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Input/UpdateDataSourceRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function testRequest(): void
$expected = '
POST /v1/apis/api123/datasources/dataSourceName HTTP/1.1
Content-type: application/json
Accept: application/json
{
"description": "This is a description",
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Input/UpdateResolverRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function testRequest(): void
$expected = '
POST /v1/apis/api123/types/type/resolvers/field HTTP/1.1
Content-type: application/json
Accept: application/json
{
"cachingConfig": {
Expand Down

0 comments on commit 7236ddb

Please sign in to comment.