Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty security array incorrectly converted to empty object (YAML) #52

Closed
coatesap opened this issue Jan 2, 2020 · 4 comments · Fixed by #59
Closed

Empty security array incorrectly converted to empty object (YAML) #52

coatesap opened this issue Jan 2, 2020 · 4 comments · Fixed by #59
Labels
bug Something isn't working
Milestone

Comments

@coatesap
Copy link

coatesap commented Jan 2, 2020

When using $schema = Reader::readFromYaml($content) followed by Writer::writeToYaml($schema) any instances of security: [] are incorrectly converted to security: { }. This is invalid (it should remain as an empty array) and causes any tooling that reads the newly written spec to fall over.

@coatesap
Copy link
Author

coatesap commented Jan 2, 2020

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

@cebe
Copy link
Owner

cebe commented Feb 20, 2020

@cebe cebe added the bug Something isn't working label Feb 20, 2020
@coatesap
Copy link
Author

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...

@cebe
Copy link
Owner

cebe commented Feb 28, 2020

if there is no valid case where an empty object needs to represent something else, we can apply this change.

@cebe cebe added this to the 1.4 milestone Feb 28, 2020
cebe added a commit that referenced this issue Mar 6, 2020
@cebe cebe closed this as completed in #59 Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants