Skip to content

Commit 2a41063

Browse files
author
Valentin Dorodnov
committed
Added opportunity for use additional flags for json_encode() function in \cebe\openapi\Writer::writeToJson().
Example JSON_UNESCAPED_UNICODE for non-latin chars.
1 parent 2224846 commit 2a41063

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Writer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ class Writer
2020
/**
2121
* Convert OpenAPI spec object to JSON data.
2222
* @param SpecObjectInterface|OpenApi $object the OpenApi object instance.
23+
* @param int $flags json_encode() flags
2324
* @return string JSON string.
2425
*/
25-
public static function writeToJson(SpecObjectInterface $object): string
26+
public static function writeToJson(SpecObjectInterface $object, int $flags = JSON_PRETTY_PRINT): string
2627
{
27-
return json_encode($object->getSerializableData(), JSON_PRETTY_PRINT);
28+
return json_encode($object->getSerializableData(), $flags);
2829
}
2930

3031
/**

0 commit comments

Comments
 (0)