#1391: add generated doc cleaning script (#2077)
* #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.
2022-09-20 12:43:39 +02:00
|
|
|
// 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,
|
2022-09-21 11:24:25 +02:00
|
|
|
'"path":["ushosted",',
|
#1391: add generated doc cleaning script (#2077)
* #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.
2022-09-20 12:43:39 +02:00
|
|
|
],
|
2022-09-21 11:24:25 +02:00
|
|
|
to: ['', '"<your-unleash-url>"', '"path":['],
|
#1391: add generated doc cleaning script (#2077)
* #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.
2022-09-20 12:43:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
replace(options);
|