Skip to content

Support custom downloadUrl for versions #859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions demo/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,16 @@ const config: Config = {
version: "2.0.0", // Current version
label: "v2.0.0", // Current version label
baseUrl: "/petstore_versioned/swagger-petstore-yaml", // Leading slash is important
downloadUrl:
"https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml",
versions: {
"1.0.0": {
specPath: "examples/petstore-1.0.0.yaml",
outputDir: "docs/petstore_versioned/1.0.0", // No trailing slash
label: "v1.0.0",
baseUrl: "/petstore_versioned/1.0.0/swagger-petstore-yaml", // Leading slash is important
downloadUrl:
"https://redocly.com/_spec/docs/openapi/petstore.json",
},
},
} satisfies OpenApiPlugin.Options,
Expand Down
2 changes: 2 additions & 0 deletions packages/docusaurus-plugin-openapi-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ custom_edit_url: null
version: version,
label: metadata.label,
baseUrl: metadata.baseUrl,
downloadUrl: metadata.downloadUrl,
});
}

Expand Down Expand Up @@ -685,6 +686,7 @@ custom_edit_url: null
delete parentConfig.version;
delete parentConfig.label;
delete parentConfig.baseUrl;
delete parentConfig.downloadUrl;

// TODO: handle when no versions are defined by version command is passed
if (versionId === "all") {
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-openapi-docs/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const OptionsSchema = Joi.object({
outputDir: Joi.string().required(),
label: Joi.string().required(),
baseUrl: Joi.string().required(),
downloadUrl: Joi.string(),
})
),
})
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-openapi-docs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface APIVersionOptions {
outputDir: string;
label: string;
baseUrl: string;
downloadUrl?: string;
}

export interface LoadedContent {
Expand Down
Loading