Skip to content

[Yaml] Yaml::dump() inserts unneeded newlines for arrays #15782

Closed
@johnknl

Description

@johnknl

I'm sure I'm not the first to notice, and maybe I didn't search well enough, but couldn't find an existing issue regarding this.

Yaml::dump() will produce arrays like this:

parameters:
  -
    name: username
    in: path
    description: 'name that need to be deleted'
    required: true
    type: string
  -
    in: body
    name: body
    description: 'Updated user object'
    required: true
    schema:
      $ref: '#/definitions/User'

Instead of the more readable and preferred:

parameters:
  - name: username
    in: path
    description: 'name that need to be deleted'
    required: true
    type: string
  - in: body
    name: body
    description: 'Updated user object'
    required: true
    schema:
      $ref: '#/definitions/User'

I first noticed this using "incenteev/composer-parameter-handler" (no mention of the issue there either), which will produce this:

# This file is auto-generated during the composer install
imports:
    -
        resource: parameters_base.yml

From a parameters.yml.dist which looks like this:

imports:
    - { resource: parameters_base.yml }

Obviously the inlining is configurable in Yaml:dump, the extra newline, as far as I can tell, is not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions