From b426ffea95165b8c6c59b888a3235edcbfe579b7 Mon Sep 17 00:00:00 2001 From: DjordyKoert Date: Fri, 17 Nov 2023 17:23:24 +0100 Subject: [PATCH] fix(openapi): invalid hydra type specification --- features/openapi/docs.feature | 3 ++- src/Hydra/JsonSchema/SchemaFactory.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/features/openapi/docs.feature b/features/openapi/docs.feature index 18f09998c8b..ae109da6012 100644 --- a/features/openapi/docs.feature +++ b/features/openapi/docs.feature @@ -238,7 +238,8 @@ Feature: Documentation support "type": "string" }, "property": { - "type": ["string", "null"] + "type": "string", + "nullable": true }, "required": { "type": "boolean" diff --git a/src/Hydra/JsonSchema/SchemaFactory.php b/src/Hydra/JsonSchema/SchemaFactory.php index 540834d92f5..30c41e01f30 100644 --- a/src/Hydra/JsonSchema/SchemaFactory.php +++ b/src/Hydra/JsonSchema/SchemaFactory.php @@ -92,12 +92,12 @@ public function buildSchema(string $className, string $format = 'jsonld', string unset($schema['items']); switch ($schema->getVersion()) { - // JSON Schema + OpenAPI 3.1 case Schema::VERSION_OPENAPI: + $nullableStringDefinition = ['type' => 'string', 'nullable' => true]; + break; case Schema::VERSION_JSON_SCHEMA: $nullableStringDefinition = ['type' => ['string', 'null']]; break; - // Swagger default: $nullableStringDefinition = ['type' => 'string']; break;