diff --git a/src/Hydra/JsonSchema/SchemaFactory.php b/src/Hydra/JsonSchema/SchemaFactory.php index 41e68fdd348..83273f1fc87 100644 --- a/src/Hydra/JsonSchema/SchemaFactory.php +++ b/src/Hydra/JsonSchema/SchemaFactory.php @@ -74,6 +74,17 @@ public function buildSchema(string $className, string $format = 'jsonld', string $items = $schema['items']; unset($schema['items']); + switch ($schema->getVersion()) { + case Schema::VERSION_JSON_SCHEMA: + $mappingPropDefinition = ['type' => ['string', 'null']]; + break; + case Schema::VERSION_OPENAPI: + $mappingPropDefinition = ['type' => 'string', 'nullable' => true]; + break; + default: + $mappingPropDefinition = ['type' => 'string']; + } + $schema['type'] = 'object'; $schema['properties'] = [ 'hydra:member' => [ @@ -121,7 +132,7 @@ public function buildSchema(string $className, string $format = 'jsonld', string 'properties' => [ '@type' => ['type' => 'string'], 'variable' => ['type' => 'string'], - 'property' => ['type' => 'string'], + 'property' => $mappingPropDefinition, 'required' => ['type' => 'boolean'], ], ],