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

root level paths `/` are not split correctly

Open LukeHagar opened this issue 1 year ago • 1 comments

Describe the bug

When running the redocly split command the openapi path at the API root: / is not properly moved to the paths folder, and the references in the document are not properly converted to file based references.

To Reproduce Steps to reproduce the behavior:

Minimum repro repo: https://github.com/LukeHagar/redocly-split-repro

  1. Open the repo
  2. Run make repro
  3. See the file here: https://github.com/LukeHagar/redocly-split-repro/blob/main/openapi/paths.yaml

Expected behavior

I would expect this path to be handled like all the others

Redocly Version(s)

1.18.0

Node.js Version(s)

v20.15.0

Additional context

You rock! I love the bundle and split implementations

LukeHagar avatar Jul 16 '24 17:07 LukeHagar

I confirm this is a bug. The issue is that the tool attempts to create a file named after the path item, and since it's empty (the slash doesn't count here), it fails to resolve it. The solution I propose is to give a default name for the root path. @LukeHagar, what name would you expect here?

NB: A temporary workaround would be to rename the / path item in your OpenAPI file to an arbitrary unique value (e.g., /root), then split it, and then rename it back in the generated files (leaving the file name intact).

tatomyr avatar Jul 19 '24 09:07 tatomyr