Skip to main content

Why Files Were Deleted & How to Restore

What was deleted (from git status)

  • docs/api/onramp/ – entire folder (e.g. onramp-1-user-login.api.mdx, onramp-2-fetch-kyc-status.api.mdx, etc.)
  • docs/api/offramp/ – entire folder (e.g. offramp-1-user-login.api.mdx, etc.)
  • docs/On-Ramp/Overview.md

Why it happened

The npm run gen-api-docs script in package.json does this:

rm -rf docs/api && docusaurus gen-api-docs all && ...

So it removes the whole docs/api folder before generating API docs from swagger.yaml.
The plugin then only creates a flat layout under docs/api/ (e.g. 1-user-login.api.mdx, 2-fetch-kyc-status.api.mdx).
It does not recreate docs/api/onramp/ or docs/api/offramp/.

So when gen-api-docs was run:

  1. rm -rf docs/api deleted everything in docs/api, including:
    • docs/api/onramp/ and all its .api.mdx files
    • docs/api/offramp/ and all its .api.mdx files
    • Any other custom files under docs/api/
  2. The plugin only wrote the new flat files (api/1-user-login.api.mdx, etc.).

That’s why the onramp/offramp files and anything else only in docs/api disappeared.

How to restore the deleted files

From the repo root, run:

# Restore deleted API onramp/offramp folders and On-Ramp overview
git checkout HEAD -- docs/api/onramp/ docs/api/offramp/ docs/On-Ramp/

That brings back the deleted files from the last commit.
If some of those were already deleted in an earlier commit, use:

git checkout <commit-before-gen-api-docs> -- docs/api/onramp/ docs/api/offramp/ docs/On-Ramp/

(replace <commit-before-gen-api-docs> with the commit hash from before you ran gen-api-docs).

After restoring

  • Your sidebars were changed to use the flat doc ids (e.g. api/1-user-login).
    If you want to use the onramp/offramp structure again, the sidebars (and any links in guides) need to point back to api/onramp/onramp-* and api/offramp/offramp-*.
  • You will then have both:
    • Flat API docs: api/1-user-login.api.mdx, etc.
    • Onramp/Offramp docs: api/onramp/..., api/offramp/...
      You can either keep both and wire sidebars to one set, or remove the flat duplicates if you only use onramp/offramp.

Avoiding this in the future

  1. Don’t run gen-api-docs if you need to keep a custom docs/api structure (e.g. onramp/offramp), or
  2. Change the script so it doesn’t wipe the whole folder, for example:
    • Remove rm -rf docs/api and only delete/regenerate the files the plugin actually creates, or
    • Generate into a temp dir and then merge/copy into docs/api without deleting onramp/offramp.