Redocly / redocly-cli

⚒️ Redocly CLI makes OpenAPI easy. Lint/validate to any standard, generate beautiful docs, and more.
https://redocly.com/docs/cli/
MIT License
933 stars 146 forks source link

1.23.0 release caused breaking change in bundle output option when APIs are not specified #1776

Open imdex-brett-debeer opened 1 week ago

imdex-brett-debeer commented 1 week ago

Describe the bug

Release 1.23.0 introduced #1715. Fix #1717 resolved the issue when API names are provided as arguments but did not correct the problem when no API names are provided.

To Reproduce

We have the following make command to bundle some spec files:

npx @redocly/cli bundle -o ./generated/

As of 1.23.0, it outputs a single file named generated.yaml in the ./ folder:

.
└── generated.yaml

Expected behavior

Before, it would output one file per spec file to the ./generated/ folder.

.
├── generated
    ├── some_spec_file.yaml
    ├── another_spec_file.yaml
    └── ...

OpenAPI description

OAS 3.0.0

Redocly Version(s)

I've tried the following versions but expect it applies to all versions since 1.23.0

Node.js Version(s)

v20.10.0

OS, environment

Ubuntu 22.04.5 LTS in WSL on Windows 11

Additional context

Changing redocly-cli/packages/cli/src/commands/bundle.ts line 78 to the below might solve the problem.

        entries: apis.length,
tatomyr commented 1 week ago

Before, it would output one file per spec file in API_FILES to the ./generated/ folder.

Hi @imdex-brett-debeer, could you clarify what you mean by API_FILES?

Are you using redocly.yaml file with the apis section specified? If yes, you can specify the output filenames for each entry as in this example from the docs:

apis:
  orders@v1:
    root: orders/openapi.yaml
    output: dist/orders.json
  accounts@v1:
    root: accounts/openapi.yaml
    output: dist/accounts.json
imdex-brett-debeer commented 1 week ago

Hi @tatomyr,

Apologies API_FILES was copied from #1715 by mistake.

I've created redocly-bundle-repro as a minimal reproduction.

tatomyr commented 1 week ago

Thanks! I’d still recommend defining the output paths explicitly in your config file though. The issue with the previous behaviour is that some might refer to the same API description file multiple times in the apis section with different decorators so they'll be stored under the same name, making it unclear which exact bundle gets stored in the output.