Skip to content

Commit 8ea889e

Browse files
authored
Support custom downloadUrl for versions (#859)
* support downloadUrl for versions * demonstrate version downloadUrl
1 parent 1122d94 commit 8ea889e

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

demo/docusaurus.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,16 @@ const config: Config = {
222222
version: "2.0.0", // Current version
223223
label: "v2.0.0", // Current version label
224224
baseUrl: "/petstore_versioned/swagger-petstore-yaml", // Leading slash is important
225+
downloadUrl:
226+
"https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml",
225227
versions: {
226228
"1.0.0": {
227229
specPath: "examples/petstore-1.0.0.yaml",
228230
outputDir: "docs/petstore_versioned/1.0.0", // No trailing slash
229231
label: "v1.0.0",
230232
baseUrl: "/petstore_versioned/1.0.0/swagger-petstore-yaml", // Leading slash is important
233+
downloadUrl:
234+
"https://redocly.com/_spec/docs/openapi/petstore.json",
231235
},
232236
},
233237
} satisfies OpenApiPlugin.Options,

packages/docusaurus-plugin-openapi-docs/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ custom_edit_url: null
531531
version: version,
532532
label: metadata.label,
533533
baseUrl: metadata.baseUrl,
534+
downloadUrl: metadata.downloadUrl,
534535
});
535536
}
536537

@@ -685,6 +686,7 @@ custom_edit_url: null
685686
delete parentConfig.version;
686687
delete parentConfig.label;
687688
delete parentConfig.baseUrl;
689+
delete parentConfig.downloadUrl;
688690

689691
// TODO: handle when no versions are defined by version command is passed
690692
if (versionId === "all") {

packages/docusaurus-plugin-openapi-docs/src/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const OptionsSchema = Joi.object({
5959
outputDir: Joi.string().required(),
6060
label: Joi.string().required(),
6161
baseUrl: Joi.string().required(),
62+
downloadUrl: Joi.string(),
6263
})
6364
),
6465
})

packages/docusaurus-plugin-openapi-docs/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface APIVersionOptions {
7070
outputDir: string;
7171
label: string;
7272
baseUrl: string;
73+
downloadUrl?: string;
7374
}
7475

7576
export interface LoadedContent {

0 commit comments

Comments
 (0)