1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-28 19:06:12 +01:00
unleash.unleash/website/clean-generated-docs.js
Thomas Heartman 29da625195
chore: update docusaurus/openapi integration to stable version (#2414)
## What

This PR updates the version of the docusaurus-openapi plugin we depend
on for openapi docs generation from canary version 0.0.0-514 to stable
release 1.4.4.

Also removes the manual file cleanup that was created as a workaround to
solve the issues we were having.

## Why

When we set the canary version before the weekend it was because it
contained a fix of some of the issues we were having with our docs.

That issue (and the one about file cleanup) have now been released in
v1.4.4, so we can upgrade to a stable version and remove now-redundant
cleanup code.
2022-11-14 08:52:46 +01:00

31 lines
1.0 KiB
JavaScript

// Description:
//
// ## What
//
// This script replaces all references to the Unleash ushosted instance in the
// generated OpenAPI docs. It removes extra path segments (such as leading
// `/ushosted` instances) and replaces the ushosted base url with something
// user-agnostic.
//
// ## Why
//
// When we host the OpenAPI docs in our official documentation, the generated
// docs shouldn't necessarily point at _one specific instance_, and especially
// not one that the reader is unlikely to ever use. Instead, we can remove all
// the bits that are specific to the generation source we use, and make the docs
// easier to use. In particular, removing the leading `/ushosted` is likely to
// save us loooots of questions.
const replace = require('replace-in-file');
const options = {
files: 'docs/reference/api/**/*.api.mdx',
from: [
/\/ushosted/g,
/"https:\/\/us.app.unleash-hosted.com(\/ushosted)?"/g,
'"path":["ushosted",',
],
to: ['', '"<your-unleash-url>"', '"path":['],
};
replace(options);