diff --git a/docs/api/oas/favicon-16x16.png b/docs/api/oas/favicon-16x16.png
deleted file mode 100644
index 8b194e617a..0000000000
Binary files a/docs/api/oas/favicon-16x16.png and /dev/null differ
diff --git a/docs/api/oas/favicon-32x32.png b/docs/api/oas/favicon-32x32.png
deleted file mode 100644
index 249737fe44..0000000000
Binary files a/docs/api/oas/favicon-32x32.png and /dev/null differ
diff --git a/docs/api/oas/index.html b/docs/api/oas/index.html
deleted file mode 100644
index 9a25d44e6f..0000000000
--- a/docs/api/oas/index.html
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
- ReDoc
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/api/oas/oauth2-redirect.html b/docs/api/oas/oauth2-redirect.html
deleted file mode 100644
index 5e6599a268..0000000000
--- a/docs/api/oas/oauth2-redirect.html
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
- Swagger UI: OAuth2 Redirect
-
-
-
-
-
diff --git a/openapi-static/Beta.svg b/openapi-static/Beta.svg
new file mode 100644
index 0000000000..262731ef3d
--- /dev/null
+++ b/openapi-static/Beta.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/openapi-static/Enterprise.svg b/openapi-static/Enterprise.svg
new file mode 100644
index 0000000000..46d73998ba
--- /dev/null
+++ b/openapi-static/Enterprise.svg
@@ -0,0 +1,7 @@
+
diff --git a/src/lib/app.ts b/src/lib/app.ts
index 44665c0e98..4b09a14a70 100644
--- a/src/lib/app.ts
+++ b/src/lib/app.ts
@@ -100,10 +100,6 @@ export default async function getApp(
app.use(baseUriPath, favicon(path.join(publicFolder, 'favicon.ico')));
app.use(baseUriPath, express.static(publicFolder, { index: false }));
- if (config.enableOAS) {
- app.use(`${baseUriPath}/oas`, express.static('docs/api/oas'));
- }
-
if (config.enableOAS && services.openApiService) {
services.openApiService.useDocs(app);
}
diff --git a/src/lib/openapi/util/api-operation.ts b/src/lib/openapi/util/api-operation.ts
index 9a643884a1..bb6f47ddea 100644
--- a/src/lib/openapi/util/api-operation.ts
+++ b/src/lib/openapi/util/api-operation.ts
@@ -14,4 +14,6 @@ export interface ApiOperation
extends Omit {
operationId: string;
tags: [Tag];
+ beta?: boolean;
+ enterpriseOnly?: boolean;
}
diff --git a/src/lib/services/openapi-service.ts b/src/lib/services/openapi-service.ts
index bd410f776c..36d2ee9aab 100644
--- a/src/lib/services/openapi-service.ts
+++ b/src/lib/services/openapi-service.ts
@@ -1,5 +1,10 @@
import openapi, { type IExpressOpenApi } from '@wesleytodd/openapi';
-import type { Express, RequestHandler, Response } from 'express';
+import {
+ type Express,
+ type RequestHandler,
+ type Response,
+ static as expressStatic,
+} from 'express';
import type { IUnleashConfig } from '../types/option.js';
import {
createOpenApiSchema,
@@ -38,12 +43,40 @@ export class OpenApiService {
}
validPath(op: ApiOperation): RequestHandler {
- return this.api.validPath(op);
+ const { beta, enterpriseOnly, ...rest } = op;
+
+ const betaBadge = beta
+ ? `}/Beta.svg) This is a beta endpoint and it may change or be removed in the future.
+
+ `
+ : '';
+ const enterpriseBadge = enterpriseOnly
+ ? `}/Enterprise.svg) **Enterprise feature**
+
+ `
+ : '';
+ return this.api.validPath({
+ ...rest,
+ description:
+ `${enterpriseBadge}${betaBadge}${op.description}`.replaceAll(
+ /\n\s*/g,
+ '\n\n',
+ ),
+ });
}
useDocs(app: Express): void {
app.use(this.api);
app.use(this.docsPath(), this.api.swaggerui());
+ app.use(
+ this.docsStaticsPath(),
+ expressStatic('openapi-static', { index: false }),
+ );
+ }
+
+ docsStaticsPath(): string {
+ const { baseUriPath = '' } = this.config.server ?? {};
+ return `${baseUriPath}/docs/static`;
}
docsPath(): string {