Skip to content

Commit

Permalink
update paths to watch for handling multi-file OpenAPI docs (#219)
Browse files Browse the repository at this point in the history
* update paths to watch for handling multi-file OpenAPI docs

* Create small-poets-sing.md

* also watch the main file

Co-authored-by: Rohit Gohri <code@rohit.page>
  • Loading branch information
mauris and rohit-gohri committed Jul 9, 2022
1 parent 498514b commit 70d14f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-poets-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"docusaurus-plugin-redoc": patch
---

Update paths to watch for handling multi-file OpenAPI docs
11 changes: 9 additions & 2 deletions packages/docusaurus-plugin-redoc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function redocPlugin(
'redocusaurus',
`${options.id || 'api-spec'}.yaml`,
);
let filesToWatch: string[] = isSpecFile ? [path.resolve(spec)] : [];

if (debug) {
console.error('[REDOCUSAURUS_PLUGIN] Opts Input:', opts);
Expand Down Expand Up @@ -86,11 +87,17 @@ export default function redocPlugin(
redoclyConfig = await loadConfig();
}

const { bundle: bundledSpec, problems } = await bundle({
const {
bundle: bundledSpec,
problems,
fileDependencies,
} = await bundle({
ref: spec,
config: redoclyConfig,
});

filesToWatch = [path.resolve(spec), ...fileDependencies];

if (problems?.length) {
console.error('[REDOCUSAURUS_PLUGIN] errors while bundling spec', spec);

Expand Down Expand Up @@ -184,7 +191,7 @@ export default function redocPlugin(
if (!isSpecFile) {
return [];
}
return [path.resolve(spec)];
return filesToWatch;
},
};
}
Expand Down

1 comment on commit 70d14f9

@vercel
Copy link

@vercel vercel bot commented on 70d14f9 Jul 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.