-
-
Notifications
You must be signed in to change notification settings - Fork 177
Yaml output indentation #337
Comments
I would accept a PR to increase the indentation of sequence elements. |
Looks like it might not be possible using libyaml yaml/libyaml#224 |
fwiw, I was able to workaround this by pushing the yaml through a yaml-rust roundtrip, which defaults to the typical style of indentation in the output of sequences. |
Which style does https://github.com/pantoniou/libfyaml do? If it works better we can switch from libyaml to libfyaml. |
IMO it looks good. |
Anyone wanting to solve this with postprocessing on the CLI can use Rust tool https://github.com/xbcsmith/ymlfxr ; |
I am using https://github.com/juhaku/utoipa 's
to_yaml
which usesserde_yaml::to_string
, to generate a openapi 3 yaml file, and there is a lack of typical indentation in the output of arrays/sequences.e.g.
Typical linters, e.g. https://pypi.org/project/yamllint/, require the
- my_tag
to be indented an extra two spaces. A lot of python cloud tools use yamllint, e.g. ansible-lint. More can be seen at https://www.wheelodex.org/projects/yamllint/rdepends/ , and that is just Python. https://developers.home-assistant.io/docs/documenting/yaml-style-guide/ is another style guide which expects that indentation.I did a quick test against
serde_yaml
directly, and it looks like that the lack of indentation is the default. i.e. the following is truei.e. the indentation is dropped.
It would be great if the default could be updated.
And allow something like
serde_json::PrettyFormatter::with_indent
. It would also be handy to be able to specify other defaults, like whether strings should be enclosed in'
or"
by default. I see something similar was asked in #226The text was updated successfully, but these errors were encountered: