php-openapi icon indicating copy to clipboard operation
php-openapi copied to clipboard

Symfony YAML does not parse all YAML

Open cebe opened this issue 6 years ago • 3 comments
trafficstars

While trying to add more tests for more specs from these sources:

  • https://github.com/Mermade/openapi3-examples/tree/master/resources
  • https://github.com/Nexmo/api-specification/tree/master/definitions
  • https://github.com/APIs-guru/openapi-directory

I found that symfony YAML fails on a lot of these. We either need an alternative YAML parser or improve symfony YAML to not fail.

  • https://github.com/yaml/yaml-test-suite
  • https://github.com/symfony/symfony/issues/27965

cebe avatar Apr 25 '19 14:04 cebe

https://github.com/mustangostang/spyc/blob/master/Spyc.php

cebe avatar Nov 26 '19 22:11 cebe

I've encountered the same issue. The problem is that it parses only arrays while getSerializableData() return stdClasses.

simPod avatar Apr 07 '21 16:04 simPod

I'm using typical trick from js world:

Yaml::dump(
    json_decode(json_encode($openApiSpec->create()->getSerializableData()), true),
    flags: Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE
)

simPod avatar Apr 07 '21 16:04 simPod