Skip to content
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

feat: allow downloading openapi specs in JSON #1419

Merged
merged 1 commit into from
Jan 21, 2025
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
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module.exports = {
config: {
/** @type {import('docusaurus-plugin-openapi-docs').Options} */
v2: {
downloadUrl: 'apify-api.yaml',
downloadUrl: 'openapi.yaml',
specPath: 'apify-api.yaml',
outputDir: './sources/api',
markdownGenerators: {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"api:rebuild": "npm run api:clean && npm run api:generate",
"redoc:start": "redocly preview-docs",
"redoc:build": "redocly bundle apify-api/openapi/openapi.yaml -o apify-api",
"redoc:build:clean": "redocly bundle apify-api/openapi/openapi.yaml --skip-decorator=apify/legacy-doc-url-decorator --skip-decorator=apify/client-references-links-decorator --skip-decorator=apify/code-samples-decorator -o static/api/apify-api.yaml",
"redoc:build:clean": "npm run redoc:build:clean:yaml && npm run redoc:build:clean:json",
"redoc:build:clean:yaml": "redocly bundle apify-api/openapi/openapi.yaml --skip-decorator=apify/legacy-doc-url-decorator --skip-decorator=apify/client-references-links-decorator --skip-decorator=apify/code-samples-decorator -o static/api/openapi.yaml",
"redoc:build:clean:json": "redocly bundle apify-api/openapi/openapi.yaml --skip-decorator=apify/legacy-doc-url-decorator --skip-decorator=apify/client-references-links-decorator --skip-decorator=apify/code-samples-decorator -o static/api/openapi.json",
"redoc:test": "redocly lint && npm run redoc:build",
"redoc:test2": "redocly lint && npm run redoc:build && bin/schemathesis",
"write-translations": "docusaurus write-translations",
Expand Down
42 changes: 40 additions & 2 deletions patches/docusaurus-theme-openapi-docs+4.3.1.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/CodeSnippets/index.js b/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/CodeSnippets/index.js
index 3d43486..b21e5d5 100644
index 514066e..0d09eeb 100644
--- a/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/CodeSnippets/index.js
+++ b/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/CodeSnippets/index.js
@@ -290,7 +290,7 @@ function CodeSnippets({ postman, codeSamples }) {
@@ -286,7 +286,7 @@ function CodeSnippets({ postman, codeSamples }) {
CodeTab,
{
value: lang.language,
Expand All @@ -11,3 +11,41 @@ index 3d43486..b21e5d5 100644
key: lang.language,
attributes: {
className: `openapi-tabs__code-item--${lang.logoClass}`,
diff --git a/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/Export/index.js b/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/Export/index.js
index a2a4e40..f2d944d 100644
--- a/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/Export/index.js
+++ b/node_modules/docusaurus-theme-openapi-docs/lib/theme/ApiExplorer/Export/index.js
@@ -30,7 +30,7 @@ function Export({ url, proxy }) {
react_1.default.createElement(
"button",
{ className: "export-button button button--sm button--secondary" },
- "Export"
+ "Download OpenAPI"
),
react_1.default.createElement(
"ul",
@@ -48,7 +48,23 @@ function Export({ url, proxy }) {
className: "dropdown__link",
href: `${url}`,
},
- "OpenAPI Spec"
+ "YAML"
+ )
+ ),
+ react_1.default.createElement(
+ "li",
+ null,
+ react_1.default.createElement(
+ "a",
+ {
+ onClick: (e) => {
+ e.preventDefault();
+ saveFile(`${url.replace(/\.yaml$/, '.json')}`);
+ },
+ className: "dropdown__link",
+ href: `${url.replace(/\.yaml$/, '.json')}`,
+ },
+ "JSON"
)
)
)
Loading