diff --git a/Makefile b/Makefile index acfca9e2..0d7ca4cf 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,12 @@ fix-style: php-cs-fixer.phar $(DOCKER_PHP) vendor/bin/indent --spaces .php_cs.dist $(DOCKER_PHP) ./php-cs-fixer.phar fix src/ --diff +cli: + docker-compose run --rm php bash + +#cli_root: +# docker-compose exec --user="root" php bash + install: $(DOCKER_PHP) composer install --prefer-dist --no-interaction --no-progress --ansi $(DOCKER_NODE) yarn install diff --git a/composer.json b/composer.json index a3054a52..7bbadcae 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": ">=7.1.0", "ext-json": "*", - "symfony/yaml": "^3.4 || ^4 || ^5 || ^6 || ^7.0", + "ext-yaml": "*", "justinrainbow/json-schema": "^5.2" }, "require-dev": { @@ -28,8 +28,6 @@ "phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4", "oai/openapi-specification": "3.0.3", "mermade/openapi3-examples": "1.0.0", - "apis-guru/openapi-directory": "1.0.0", - "nexmo/api-specification": "1.0.0", "phpstan/phpstan": "^0.12.0" }, "conflict": { diff --git a/src/Reader.php b/src/Reader.php index 99ee5c36..c229fe07 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -13,7 +13,6 @@ use cebe\openapi\json\InvalidJsonPointerSyntaxException; use cebe\openapi\json\JsonPointer; use cebe\openapi\spec\OpenApi; -use Symfony\Component\Yaml\Yaml; /** * Utility class to simplify reading JSON or YAML OpenAPI specs. @@ -54,7 +53,7 @@ public static function readFromJson(string $json, string $baseType = OpenApi::cl */ public static function readFromYaml(string $yaml, string $baseType = OpenApi::class): SpecObjectInterface { - return new $baseType(Yaml::parse($yaml)); + return new $baseType(yaml_parse($yaml)); } /** diff --git a/src/ReferenceContext.php b/src/ReferenceContext.php index bde0a964..e5233539 100644 --- a/src/ReferenceContext.php +++ b/src/ReferenceContext.php @@ -11,7 +11,6 @@ use cebe\openapi\exceptions\UnresolvableReferenceException; use cebe\openapi\json\JsonPointer; use cebe\openapi\spec\Reference; -use Symfony\Component\Yaml\Yaml; /** * ReferenceContext represents a context in which references are resolved. @@ -224,7 +223,7 @@ public function fetchReferencedFile($uri) if (strpos(ltrim($content), '{') === 0) { $parsedContent = json_decode($content, true); } else { - $parsedContent = Yaml::parse($content); + $parsedContent = yaml_parse($content); } $this->_cache->set('FILE_CONTENT://' . $uri, 'FILE_CONTENT', $parsedContent); return $parsedContent; diff --git a/src/Writer.php b/src/Writer.php index faa08f46..030ba267 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -9,7 +9,6 @@ use cebe\openapi\exceptions\IOException; use cebe\openapi\spec\OpenApi; -use Symfony\Component\Yaml\Yaml; /** * Utility class to simplify writing JSON or YAML OpenAPI specs. @@ -35,7 +34,10 @@ public static function writeToJson(SpecObjectInterface $object, int $flags = JSO */ public static function writeToYaml(SpecObjectInterface $object): string { - return Yaml::dump($object->getSerializableData(), 256, 2, Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); +// return Yaml::dump($object->getSerializableData(), 256, 2, Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); + return yaml_emit( + json_decode(json_encode($object->getSerializableData()), true) + ); } /** diff --git a/src/spec/Reference.php b/src/spec/Reference.php index cda612a9..7b37b0d8 100644 --- a/src/spec/Reference.php +++ b/src/spec/Reference.php @@ -8,7 +8,6 @@ namespace cebe\openapi\spec; use cebe\openapi\DocumentContextInterface; -use cebe\openapi\exceptions\IOException; use cebe\openapi\exceptions\TypeErrorException; use cebe\openapi\exceptions\UnresolvableReferenceException; use cebe\openapi\json\InvalidJsonPointerSyntaxException; @@ -17,7 +16,6 @@ use cebe\openapi\json\NonexistentJsonPointerReferenceException; use cebe\openapi\ReferenceContext; use cebe\openapi\SpecObjectInterface; -use Symfony\Component\Yaml\Yaml; /** * Reference Object diff --git a/tests/WriterTest.php b/tests/WriterTest.php index fc415b51..7a9f4f78 100644 --- a/tests/WriterTest.php +++ b/tests/WriterTest.php @@ -74,11 +74,13 @@ public function testWriteYaml() $this->assertEquals(preg_replace('~\R~', "\n", <<assertEquals(preg_replace('~\R~', "\n", <<assertEquals(preg_replace('~\R~', "\n", <<validate(); diff --git a/tests/spec/ReferenceTest.php b/tests/spec/ReferenceTest.php index b94c946e..a7983d00 100644 --- a/tests/spec/ReferenceTest.php +++ b/tests/spec/ReferenceTest.php @@ -1,13 +1,13 @@