Skip to content

Commit 79eb2e0

Browse files
committed
Merge 4.2
2 parents 563b21d + 5f7feec commit 79eb2e0

4 files changed

Lines changed: 83 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,57 @@ jobs:
178178
run: |
179179
./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi
180180
181+
redocly-lint:
182+
name: Lint OpenAPI with Redocly
183+
runs-on: ubuntu-latest
184+
timeout-minutes: 20
185+
strategy:
186+
matrix:
187+
php:
188+
- '8.4'
189+
fail-fast: false
190+
steps:
191+
- name: Checkout
192+
uses: actions/checkout@v6
193+
- name: Setup PHP
194+
uses: shivammathur/setup-php@v2
195+
with:
196+
php-version: ${{ matrix.php }}
197+
extensions: intl, bcmath, curl, openssl, mbstring
198+
ini-values: memory_limit=-1
199+
tools: composer
200+
coverage: none
201+
- name: Get composer cache directory
202+
id: composercache
203+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
204+
- name: Cache dependencies
205+
uses: actions/cache@v5
206+
with:
207+
path: ${{ steps.composercache.outputs.dir }}
208+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
209+
restore-keys: ${{ runner.os }}-composer-
210+
- name: Update project dependencies
211+
run: |
212+
composer global require soyuka/pmu
213+
composer global config allow-plugins.soyuka/pmu true --no-interaction
214+
composer global link .
215+
- name: Setup Node.js
216+
uses: actions/setup-node@v4
217+
with:
218+
node-version: '20'
219+
- name: Install Redocly CLI
220+
run: npm install -g @redocly/cli@latest
221+
- name: Clear test app cache
222+
run: |
223+
rm -Rf tests/Fixtures/app/var/cache/*
224+
tests/Fixtures/app/console cache:warmup
225+
- name: Generate OpenAPI spec
226+
run: |
227+
mkdir -p /tmp/openapi
228+
tests/Fixtures/app/console api:openapi:export --output=/tmp/openapi/openapi.json --no-ansi
229+
- name: Lint OpenAPI spec with Redocly
230+
run: redocly lint /tmp/openapi/openapi.json
231+
181232
phpunit:
182233
name: PHPUnit (PHP ${{ matrix.php }})
183234
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161

6262
* When using `output` with `itemUriTemplate` on a collection operation, the JSON-LD `@type` will now use the resource class name instead of the output DTO class name for semantic consistency with `itemUriTemplate` behavior.
6363

64+
## v4.2.18
65+
66+
### Bug fixes
67+
68+
* [2e0b8ffb6](https://github.com/api-platform/core/commit/2e0b8ffb6b57ee5552ad8a48b212d8dff9de923a) fix(serializer): prevent api_platform_output context from leaking to nested non-resource objects (#7787)
69+
* [64247b050](https://github.com/api-platform/core/commit/64247b0505dd0bcb79e958b1f987e983eb6c3fd3) fix(metadata): sort parameters by priority after pattern expansion (#7788)
70+
* [90dfc3554](https://github.com/api-platform/core/commit/90dfc355496d9f6478f3085d96f146082552a9d2) fix(validator): handle nested groups and group sequences (#7784, #7791)
71+
* [9f1109365](https://github.com/api-platform/core/commit/9f1109365cc44a21551c77f715dcd0bbed1b161f) fix(hydra): example type - use @type prefix per JSON-LD spec (#7768)
72+
* [c624daf68](https://github.com/api-platform/core/commit/c624daf68e4ca5a5a0a0dcd95e61b5ea8b154958) fix(symfony): allow toggling GraphQL Playground to ensure BC
73+
6474
## v4.2.17
6575

6676
### Bug fixes
@@ -3964,4 +3974,4 @@ Please read #2825 if you have issues with the behavior of Readable/Writable Link
39643974
## 1.0.0 beta 2
39653975

39663976
* Preserve indexes when normalizing and denormalizing associative arrays
3967-
* Allow setting default order for property when registering a `Doctrine\Orm\Filter\OrderFilter` instance
3977+
* Allow setting default order for property when registering a `Doctrine\Orm\Filter\OrderFilter` instance

src/Hydra/JsonSchema/SchemaFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function buildSchema(string $className, string $format = 'jsonld', string
229229
],
230230
'example' => [
231231
'@id' => 'string',
232-
'type' => 'string',
232+
'@type' => 'string',
233233
$hydraPrefix.'first' => 'string',
234234
$hydraPrefix.'last' => 'string',
235235
$hydraPrefix.'previous' => 'string',

tests/Functional/JsonSchema/JsonLdJsonSchemaTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,26 @@ public function testSchemaJsonLdCollection(): void
163163
$this->assertEquals(['$ref' => '#/definitions/BagOfTests.jsonld-read'], $schema['allOf'][1]['properties']['hydra:member']['items']);
164164
}
165165

166+
public function testHydraCollectionBaseSchemaExample(): void
167+
{
168+
$schema = $this->schemaFactory->buildSchema(BagOfTests::class, 'jsonld', forceCollection: true);
169+
170+
$this->assertArrayHasKey('HydraCollectionBaseSchema', $schema['definitions']);
171+
$hydraCollectionSchema = $schema['definitions']['HydraCollectionBaseSchema'];
172+
173+
// Navigate to the hydra:view property example
174+
$this->assertArrayHasKey('allOf', $hydraCollectionSchema);
175+
$viewProperty = $hydraCollectionSchema['allOf'][1]['properties']['hydra:view'] ?? null;
176+
$this->assertNotNull($viewProperty, 'hydra:view property should exist');
177+
178+
// Check that the example uses @type instead of type
179+
$this->assertArrayHasKey('example', $viewProperty);
180+
$example = $viewProperty['example'];
181+
$this->assertArrayHasKey('@type', $example, 'Example should use @type with @ prefix');
182+
$this->assertArrayNotHasKey('type', $example, 'Example should not use type without @ prefix');
183+
$this->assertArrayHasKey('@id', $example, 'Example should have @id');
184+
}
185+
166186
public function testArraySchemaWithMultipleUnionTypes(): void
167187
{
168188
$schema = $this->schemaFactory->buildSchema(Nest::class, 'jsonld', 'output');

0 commit comments

Comments
 (0)