Skip to content

[docs] Render the Moodle Marketplace API reference with Redocusaurus - #1716

Draft
vmdef wants to merge 1 commit into
moodle:mainfrom
vmdef:marketplace-api-reference
Draft

vmdef wants to merge 1 commit into
moodle:mainfrom
vmdef:marketplace-api-reference

Conversation

@vmdef

@vmdef vmdef commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the hand-written Moodle Marketplace API guide with a reference generated from the Marketplace OpenAPI spec (https://marketplace.next.moodle.org/api/docs.jsonopenapi), rendered with Redocusaurus.

  • Same page, new content: general/community/plugincontribution/moodlemarketplaceapi.md becomes .mdx and embeds the reference with <ApiDocMdx id="marketplace-api" />. The URL, sidebar position and tags are unchanged. The link to it from pluginsdirectory/api.md is now relative (../moodlemarketplaceapi.mdx).
  • Always up to date: docusaurus.config.js now exports an async function that fetches the spec before every start/build.
  • Fallback: a copy of the spec is committed at static/marketplace-api/openapi.json. If the Marketplace is unreachable, times out (15 seconds) or returns something that isn't an OpenAPI spec, the build logs a warning and uses that copy. The build only fails if no copy exists. The file is only rewritten when the spec changes. It is also served at /marketplace-api/openapi.json for Redoc's Download button.
  • Links: site-relative links in the spec (e.g. /account/security) are rewritten to point to the Marketplace, since they can't be changed there.
  • Layout: Redoc's menu is shown on the right, like the table of contents on other pages. The sticky "Edit this page / Last updated" bar gets z-index: 2 so Redoc's content (z-index: 1) no longer shows through it.
  • Dependencies: adds redocusaurus, plus its peer dependencies @docusaurus/theme-common and @docusaurus/utils at our Docusaurus version.

All page content now comes from the spec. Any wording changes should be made in the Marketplace.

Testing

  • yarn jest src/utils: 11 tests for updateMarketplaceApiSpec, with fetch and fs/promises mocked:
    • Valid spec: fetches with a 15-second timeout, writes the spec with links rewritten, creates the copy if missing, and skips the write when nothing changed.
    • Fallback: an HTTP error, a timeout, a network error, a non-JSON response, JSON that isn't OpenAPI, and OpenAPI without paths each fall back to the committed copy with a single warning.
    • No local copy: the build fails with a clear error.
  • ESLint, stylelint, markdownlint and cspell pass on the changed files.
  • Checked on yarn start: the page renders in the docs layout with the Redoc menu on the right, the security settings link points to the Marketplace, the Download button serves the committed spec, and the sticky footer bar covers the content correctly.
  • A full production build was not run locally.

🤖 Generated with Claude Code

@vmdef
vmdef requested a review from a team as a code owner October 1, 2026 12:14
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:14
@netlify

netlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for moodledevdocs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d2333c2
🔍 Latest deploy log https://app.netlify.com/projects/moodledevdocs/deploys/6abe66c42d77410008aaf54f
😎 Deploy Preview https://deploy-preview-1716--moodledevdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The reference has an incorrect API server URL, incomplete fallback validation, and broken or unusable documentation links and instructions.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Replaces the hand-written Marketplace API guide with a Redocusaurus-rendered OpenAPI reference and build-time refresh mechanism.

Changes:

  • Adds Redocusaurus integration and dependencies.
  • Fetches, rewrites, and caches the Marketplace OpenAPI specification.
  • Converts the guide to MDX and adds link-rewriting tests.
File Description
docusaurus.config.js Configures Redocusaurus and refreshes the specification.
package.json Adds Redocusaurus dependencies.
yarn.lock Locks new dependencies.
src/​utils/​marketplaceApiSpec.js Implements fetching, rewriting, and fallback behavior.
src/​utils/​marketplaceApiSpec.test.js Tests link rewriting.
static/​marketplace-api/​openapi.json Provides the fallback OpenAPI specification.
general/​community/​plugincontribution/​moodlemarketplaceapi.md Removes the hand-written guide.
general/​community/​plugincontribution/​moodlemarketplaceapi.mdx Embeds the generated reference.
general/​community/​plugincontribution/​pluginsdirectory/​api.md Updates the Marketplace API link.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/marketplaceApiSpec.js
Comment thread general/community/plugincontribution/pluginsdirectory/api.md Outdated
Comment thread static/marketplace-api/openapi.json
@vmdef
vmdef marked this pull request as draft October 1, 2026 12:20
Replace the hand-written Moodle Marketplace API guide with a reference
generated from the Marketplace OpenAPI spec using Redocusaurus.

The spec is fetched from the Marketplace on every start and build, so the
reference stays up to date. A copy is committed in static/ and used if the
Marketplace is unreachable. Site-relative links in the spec are rewritten
to point to the Marketplace.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vmdef
vmdef force-pushed the marketplace-api-reference branch from 2ef68da to d2333c2 Compare October 1, 2026 13:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants