From 3bca6422f79f1e3d2a7f1a709c9e4892310fd13d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 07:45:22 +0000 Subject: [PATCH 1/4] Initial plan From daf1e9b8abb37196162e062370ce90329f8b513d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 08:07:12 +0000 Subject: [PATCH 2/4] Improve InvalidSchemaMediaTypeException to include actual media type Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com> --- CHANGELOG.md | 2 ++ composer.json | 6 ++++++ src/JsonSchema/Uri/UriRetriever.php | 2 +- tests/Uri/UriRetrieverTest.php | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df3ba26e..7b9a1059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- UriRetriever: Include actual media type in InvalidSchemaMediaTypeException message ## [6.6.4] - 2025-12-19 ### Changed diff --git a/composer.json b/composer.json index 5dfe65d1..e29c599f 100644 --- a/composer.json +++ b/composer.json @@ -79,5 +79,11 @@ "testOnly": "phpunit --colors --filter", "phpstan": "@php phpstan", "phpstan-generate-baseline": "@php phpstan --generate-baseline" + }, + "config": { + "use-github-api": false, + "github-protocols": ["git", "https"], + "secure-http": true, + "disable-tls": false } } diff --git a/src/JsonSchema/Uri/UriRetriever.php b/src/JsonSchema/Uri/UriRetriever.php index 361512a9..8a6110d6 100644 --- a/src/JsonSchema/Uri/UriRetriever.php +++ b/src/JsonSchema/Uri/UriRetriever.php @@ -91,7 +91,7 @@ public function confirmMediaType($uriRetriever, $uri) } } - throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE)); + throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected, but %s given', Validator::SCHEMA_MEDIA_TYPE, $contentType)); } /** diff --git a/tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php index 4e791768..e14f2205 100644 --- a/tests/Uri/UriRetrieverTest.php +++ b/tests/Uri/UriRetrieverTest.php @@ -263,6 +263,20 @@ public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes(): void $retriever->confirmMediaType($uriRetriever, null); } + public function testConfirmMediaTypeExceptionIncludesActualMediaType(): void + { + $uriRetriever = $this->createMock(\JsonSchema\Uri\Retrievers\UriRetrieverInterface::class); + $retriever = new UriRetriever(); + $uriRetriever->expects($this->at(0)) + ->method('getContentType') + ->willReturn('text/html'); + + $this->expectException(InvalidSchemaMediaTypeException::class); + $this->expectExceptionMessage('Media type application/schema+json expected, but text/html given'); + + $retriever->confirmMediaType($uriRetriever, null); + } + private function mockRetriever($schema): void { $retrieverMock = $this->getRetrieverMock($schema); From 889ca067ad8e836a743b28990fb061f722693243 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 08:08:50 +0000 Subject: [PATCH 3/4] Remove unrelated composer.json changes Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com> --- composer.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/composer.json b/composer.json index e29c599f..5dfe65d1 100644 --- a/composer.json +++ b/composer.json @@ -79,11 +79,5 @@ "testOnly": "phpunit --colors --filter", "phpstan": "@php phpstan", "phpstan-generate-baseline": "@php phpstan --generate-baseline" - }, - "config": { - "use-github-api": false, - "github-protocols": ["git", "https"], - "secure-http": true, - "disable-tls": false } } From d1db575422e4c2466b7eca14ef51282444e4aaad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 09:07:01 +0000 Subject: [PATCH 4/4] Add PR link to CHANGELOG entry Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b9a1059..fb264f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- UriRetriever: Include actual media type in InvalidSchemaMediaTypeException message +- UriRetriever: Include actual media type in InvalidSchemaMediaTypeException message ([#872](https://github.com/jsonrainbow/json-schema/pull/872)) ## [6.6.4] - 2025-12-19 ### Changed