Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #1391: add generated doc cleaning script ## What The cleaning 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. * #1391: change env var used for generating openapi from localhost Using NODE_ENV=development doesn't necessarily make sense, so adding an extra variable sounds reasonable to me. * #1391: ensure that all generation commands also clean docs * #1391: change <your-unleash-instance-url> to <your-unleash-url> * #1391: fix ushosted replacement: not all paths start with /api * #1391: chore: remove potential `ushosted` ending of api url In the event that we change the base URL of OpenAPI, so that paths don't start with `/ushosted/`, the script should still work, changing those paths into <your-unleash-url> too. Additionally, remove all instances of `/ushosted` that we find. In the event that some things switch around or whatever.
- Loading branch information
1 parent
1b1dcea
commit 0a99dfd
Showing
4 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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","api"', | ||
], | ||
to: ['', '"<your-unleash-url>"', '"path":["api"'], | ||
}; | ||
|
||
replace(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0a99dfd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
unleash – ./website
unleash-tawny.vercel.app
unleash-git-main-unleash-team.vercel.app
unleash-unleash-team.vercel.app