-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use redoc options while downloading specs (#264)
- Loading branch information
1 parent
bcbaa54
commit 137373e
Showing
3 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'docusaurus-plugin-redoc': patch | ||
--- | ||
|
||
Use redoc config while loading spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { Config, Source, Document } from '@redocly/openapi-core'; | ||
import { bundle } from '@redocly/openapi-core'; | ||
|
||
/** | ||
* Based on loadAndBundleSpec from redoc. | ||
* Customized to pass custom loaded config | ||
* @see https://github.com/Redocly/redoc/blob/33be51a7a4068f44fd914314002c058a204ba0c2/src/utils/loadAndBundleSpec.ts | ||
*/ | ||
export async function loadSpecWithConfig( | ||
specUrlOrObject: object | string, | ||
config: Config, | ||
) { | ||
const bundleOpts: Parameters<typeof bundle>[0] = { | ||
config, | ||
base: process.cwd(), | ||
}; | ||
|
||
if (typeof specUrlOrObject === 'object' && specUrlOrObject !== null) { | ||
bundleOpts.doc = { | ||
source: { absoluteRef: '' } as Source, | ||
parsed: specUrlOrObject, | ||
} as Document; | ||
} else { | ||
bundleOpts.ref = specUrlOrObject; | ||
} | ||
|
||
return bundle(bundleOpts); | ||
} |
137373e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
redocusaurus – ./
redocusaurus-rohit-gohri.vercel.app
redocusaurus-v1.vercel.app
redocusaurus.vercel.app
redocusaurus-git-main-rohit-gohri.vercel.app