Skip to content

bug: Multiline descriptions with leading spaces may break overlay functionality #1927

@viktorasm

Description

@viktorasm

We have hit one case where overlay functionality gets completely broken due to unserialize-serialize-deserialize of YAML files and apparently is caused by a bug in underlying yaml library (go-yaml/yaml#1071).

This API spec works fine if not using overlay functionality:

openapi: 3.0.1
info: {}
paths:
  /info:
    get:
      parameters:
        - description: |2-
              a
            b
          name: filter
          schema:
            type: string
          in: query
      responses: {}

However, once overlay is added, tool fails with an error:

error loading swagger spec in spec.yaml
: failed to parse spec from "spec.yaml": yaml: line 8: did not find expected key

It seems like it's because LoadSwaggerWithOverlay re-marshals the spec into this:

info:
    title: ""
    version: ""
openapi: 3.0.1
paths:
    /info:
        get:
            parameters:
                - description: |4-
                      a
                    b
                  in: query
                  name: filter
                  schema:
                    type: string
            responses: {}

.. which is no longer a valid YAML.

This seems to be specific to parameter list though; if adding description to "get" directly, this bug does not appear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions