Skip to content

Commit

Permalink
fix: add hydra:previous to the hydra view schema properties
Browse files Browse the repository at this point in the history
  • Loading branch information
coudenysj committed Jun 8, 2021
1 parent e32b4e8 commit d9fad5e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions features/openapi/docs.feature
Expand Up @@ -146,6 +146,10 @@ Feature: Documentation support
"type": "string",
"format": "iri-reference"
},
"hydra:previous": {
"type": "string",
"format": "iri-reference"
},
"hydra:next": {
"type": "string",
"format": "iri-reference"
Expand Down
4 changes: 4 additions & 0 deletions src/Hydra/JsonSchema/SchemaFactory.php
Expand Up @@ -133,6 +133,10 @@ public function buildSchema(string $className, string $format = 'jsonld', string
'type' => 'string',
'format' => 'iri-reference',
],
'hydra:previous' => [
'type' => 'string',
'format' => 'iri-reference',
],
'hydra:next' => [
'type' => 'string',
'format' => 'iri-reference',
Expand Down
14 changes: 14 additions & 0 deletions tests/Hydra/JsonSchema/SchemaFactoryTest.php
Expand Up @@ -136,4 +136,18 @@ public function testSchemaTypeBuildSchema(): void
$this->assertArrayHasKey('@type', $properties);
$this->assertArrayHasKey('@id', $properties);
}

public function testHasHydraViewNavigationBuildSchema(): void
{
$resultSchema = $this->schemaFactory->buildSchema(Dummy::class, 'jsonld', Schema::TYPE_OUTPUT, OperationType::COLLECTION);

$this->assertNull($resultSchema->getRootDefinitionKey());
$this->assertArrayHasKey('properties', $resultSchema);
$this->assertArrayHasKey('hydra:view', $resultSchema['properties']);
$this->assertArrayHasKey('properties', $resultSchema['properties']['hydra:view']);
$this->assertArrayHasKey('hydra:first', $resultSchema['properties']['hydra:view']['properties']);
$this->assertArrayHasKey('hydra:last', $resultSchema['properties']['hydra:view']['properties']);
$this->assertArrayHasKey('hydra:previous', $resultSchema['properties']['hydra:view']['properties']);
$this->assertArrayHasKey('hydra:next', $resultSchema['properties']['hydra:view']['properties']);
}
}

0 comments on commit d9fad5e

Please sign in to comment.