docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
[FR] Relative urls for `downloadUrl`
Describe the bug
Passing "/openapi.yaml" to the downloadUrl config value fails to generate a download link, it'd be great to update the isUrl() function to accept relative urls..
https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/7c7db724055db181c672c8d265daa86a4ee91350/packages/docusaurus-plugin-openapi-docs/src/index.ts#L22
Expected behavior
I would like the download link to work in development, rather than just passing a full url
Current behavior
downloadUrl only accepts fully qualified urls
Possible solution
Loosen the isUrl() function to accept urls, or allow changing the url behavior in dev v.s. in prod
Steps to reproduce
- pass
downloadUrlto an api config in docusaurus && fail to receive a download link in the UI. - I can confirm that I get a download link if I set a fully qualified url in that config value.
:tada: Thanks for opening your first issue here! Welcome to the community!
Hi @jasikpark, this feature is currently not supported but you are welcome to convert this issue into a feature request by adding "[FR]" to the title and changing the label to "enhancement". Thanks!
don't think I have perms for changing labels, but i've updated the title
The downloadUrl should also support relative URL's that are pointing @site/ files. Current solution is only viable for final deploy.
A good enough workaround that I'm using:
diff --git a/packages/docusaurus-plugin-openapi-docs/src/index.ts b/packages/docusaurus-plugin-openapi-docs/src/index.ts
index 6f7c488..a7a18c6 100644
--- a/packages/docusaurus-plugin-openapi-docs/src/index.ts
+++ b/packages/docusaurus-plugin-openapi-docs/src/index.ts
@@ -311,7 +311,7 @@ custom_edit_url: null
loadedApi.map(async (item) => {
if (item.type === "info") {
- if (downloadUrl && isURL(downloadUrl)) {
+ if (downloadUrl) {
item.downloadUrl = downloadUrl;
}
}
Would love not to have to patch the package, though.
adding to roadmap with goal of supporting relative URL paths