Redocly / Redocly/redocly-cli

join should allow longer lines and retain original quotes

Open
#1,500 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3 Type: Bug
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the redocly join command and reproduce the issue using OpenAPI YAML files with long lines and quoted references. Done means joined output preserves the original long lines and required quotation marks without introducing folded blocks or invalid references.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.