Closed coatesap closed 4 years ago
It looks like the fix for this would probably be to change line 37 of Writer.php from:
return Yaml::dump($object->getSerializableData(), 256, 2, Yaml::DUMP_OBJECT_AS_MAP);
to
return Yaml::dump($object->getSerializableData(), 256, 2, Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
This may well also fix #46
Hi @cebe - does my suggestion above seem sensible, or are there any other considerations that need to be taken into account? If it looks ok, I'm happy to test it and open a PR...
if there is no valid case where an empty object needs to represent something else, we can apply this change.
When using
$schema = Reader::readFromYaml($content)
followed byWriter::writeToYaml($schema)
any instances ofsecurity: []
are incorrectly converted tosecurity: { }
. This is invalid (it should remain as an empty array) and causes any tooling that reads the newly written spec to fall over.