Redocly/redocly-cli

join --prefix-components-with-info-prop doesn't correctly handle spaces in info property

steve-nay-sage opened this issue · 1 comments

Describe the bug

If the info property used with --prefix-components-with-info-prop has spaces in the string, such as a title, the join command retains the spaces and adds some interesting (but wrong) formatting, which results in invalid schema references. (The same problem occurs with --prefix-tags, but I don't think the results break anything.)

To Reproduce
Steps to reproduce the behavior:

  1. I've attached a zip containing two YAML OAS files. They both use some of the same schema names, but with different definitions, so they can't be joined without addressing that. The info.titles values in the files have spaces in them, such as "Accounts Payable API".
  2. On a folder containing those two files, run redocly join *.yaml --prefix-components-with-info-prop title
  3. Open the resulting openapi.yaml file.
  4. Jump down to #/components/schemas and look at the schema names. You'll see that they are prefixed with the title, spaces and all.
  5. Look at line 629 as an example of a reference to one of the schemas. The join command broke it over 2 lines and tried to format it as Markdown using >-. The reference is invalid and won't work.

Expected behavior

Spaces in title values should either be replaced with an underscore or a dash, or references to any schema names that have spaces need to be in quotes. Also, I don't think it's valid to use Markdown >- in $ref.

Redocly Version(s)

1.9.1

Node.js Version(s)

18.7.0

intacct_test_files.zip

Thanks for reporting!

I think that replacing spaces with underscores is a good option (since we already use underscore to connect prefixes to components). Any objections?