From 2a41063e7eff1d7f4a5d820852c33d4345c5b626 Mon Sep 17 00:00:00 2001 From: Valentin Dorodnov Date: Thu, 17 Mar 2022 10:17:51 +0300 Subject: [PATCH 1/3] Added opportunity for use additional flags for json_encode() function in \cebe\openapi\Writer::writeToJson(). Example JSON_UNESCAPED_UNICODE for non-latin chars. --- src/Writer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Writer.php b/src/Writer.php index 997a612..dc1761e 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -20,11 +20,12 @@ class Writer /** * Convert OpenAPI spec object to JSON data. * @param SpecObjectInterface|OpenApi $object the OpenApi object instance. + * @param int $flags json_encode() flags * @return string JSON string. */ - public static function writeToJson(SpecObjectInterface $object): string + public static function writeToJson(SpecObjectInterface $object, int $flags = JSON_PRETTY_PRINT): string { - return json_encode($object->getSerializableData(), JSON_PRETTY_PRINT); + return json_encode($object->getSerializableData(), $flags); } /** From 1c4abf6103fb9ea9aae01515ef1ae7f7f672c614 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 20 Apr 2022 16:22:54 +0200 Subject: [PATCH 2/3] Update src/Writer.php --- src/Writer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Writer.php b/src/Writer.php index dc1761e..ad29c69 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -23,7 +23,7 @@ class Writer * @param int $flags json_encode() flags * @return string JSON string. */ - public static function writeToJson(SpecObjectInterface $object, int $flags = JSON_PRETTY_PRINT): string + public static function writeToJson(SpecObjectInterface $object, int $flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE): string { return json_encode($object->getSerializableData(), $flags); } From e4e00c19800e99ca4a8fbb3516e16b702147e4c7 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 20 Apr 2022 16:40:19 +0200 Subject: [PATCH 3/3] Update src/Writer.php --- src/Writer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Writer.php b/src/Writer.php index ad29c69..faa08f4 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -20,7 +20,7 @@ class Writer /** * Convert OpenAPI spec object to JSON data. * @param SpecObjectInterface|OpenApi $object the OpenApi object instance. - * @param int $flags json_encode() flags + * @param int $flags json_encode() flags. Parameter available since version 1.7.0. * @return string JSON string. */ public static function writeToJson(SpecObjectInterface $object, int $flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE): string