Unleash / unleash

Open-source feature management solution built for developers.
https://getunleash.io
Apache License 2.0
11.46k stars 721 forks source link

Fixed OpenAPI URL renaming #8726

Closed alvinometric closed 1 week ago

alvinometric commented 2 weeks ago

Problem

Our API docs are generated from a specfile that is hosted in https://us.app.unleash-hosted.com/ushosted

By default the API docs UI will show that URL, which we don't want

image

Previously

We ran a find-and-replace after the mdx files were generated with replace-in-file

Now

The previous solution is no longer possible because the openapi plugin changed. Basically, before it generated markdown files that looked like this:

# Create API Key

https://unleash-hosted/whatever

bla bla bla

Now it generates files that do not contain the URL and look like this:

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";

<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Configure project access"}
>
</Heading>

which themselves get compiled.

Solution

This PR now downloads the specfile, makes a local copy, then an alters the server URL in the copy, then uses that local file to generate the docs.

image

I didn't want to make any changes to the actual spec logic because this essentially just a plugin quirk


PREVIEW LINK

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 5:05pm
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 5:05pm
github-actions[bot] commented 2 weeks ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files