redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

join should allow longer lines and retain original quotes

Open steve-nay-sage opened this issue 5 months ago • 4 comments

Describe the bug

For some mysterious reason, the join command seems to hate long lines so it splits them into multiple shorter lines and inserts >- to indicate how newlines should be handled. Plus it strips off needed quotation marks. Here is an example of a "long" line before the join command:

  - name: Terms
    description: An Accounts Payable term is a rule that a vendor establishes for extending credit to your company. Terms can be associated with transactions or with specific vendors.

and after:

- name: Terms
    description: >-
      An Accounts Payable term is a rule that a vendor establishes for extending
      credit to your company. Terms can be associated with transactions or with
      specific vendors.

You'd be right if you thought, "That original line doesn't look very long at all!" Yes, there is no reason that I can think of for join to do anything to that line.

I'm opening this bug because turning single lines into multiple lines can cause problems for some other tools that need to parse the files produced by join. Also, when this happens with keywords other than description it can cause the schema to be invalid. For example:

    $ref: >-
      #/components/schemas/cash-management-payment-provider-bank-account

The reference needs to be in quotes. It was in quotes in the original file, but join stripped them out when it thought the line was too long. Other (shorter) references still have their quotes after join.

To Reproduce

Run redocly join on a couple of OpenAPI YAML files that have some lines that are longer than 80 characters.

Expected behavior

For long lines, the output should be exactly what the input was. There was nothing wrong with the original lines, and there is no benefit to breaking them into shorter lines. There is certainly no benefit to removing needed quotation marks-- I'd call that a bug.

Redocly Version(s)

1.10.5

Node.js Version(s)

18.7.0

Additional context

The join command is incredibly useful-- thank you! Just need to fix the little bugs that show up.

steve-nay-sage avatar Mar 22 '24 22:03 steve-nay-sage