Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

ralph(M3-CLOSE-003, operator-committed): hide /healthz from OpenAPI doc as V1 does (schema hide:true parity)

ralph30af6dd4424f
diff --git a/packages/core/src/modules/health/health.routes.ts b/packages/core/src/modules/health/health.routes.ts
index 5e53482d5..7c5fd215e 100644
--- a/packages/core/src/modules/health/health.routes.ts
+++ b/packages/core/src/modules/health/health.routes.ts
@@ -14,8 +14,14 @@ import { defineRoutes } from '../../http/define';
// no `io` argument and would collapse the input/output split the ADR requires.
const healthLiveResponseSchema = z.object({ live: z.literal(true) });
+// Hidden from the OpenAPI document — ported from V1's `schema: { hide: true }`
+// on `/healthz/live`, `/healthz/ready` and `/healthcheck`
+// (healthcheck.controller.ts): liveness probes are not part of the public API
+// contract. See verification/golden/openapi's migrated-route gate, which pins
+// `/healthz` to an empty `paths` object against V1's golden document.
export const healthRoutes = defineRoutes((app) =>
app.get('/healthz/live', () => ({ live: true as const }), {
response: healthLiveResponseSchema,
+ detail: { hide: true },
})
);
diff --git a/packages/core/src/rest.routes.test.ts b/packages/core/src/rest.routes.test.ts
index 9cbcf2017..851596492 100644
--- a/packages/core/src/rest.routes.test.ts
+++ b/packages/core/src/rest.routes.test.ts
@@ -61,7 +61,12 @@ test('/metrics serves the one core registry, prometheus text exposition', async
registry.removeSingleMetric(probeName);
});
-test('/openapi.json serves the OpenAPI document with health routes present, /metrics hidden', async () => {
+// V1 hides /healthz/live, /healthz/ready and /healthcheck from its OpenAPI
+// document (apps/api/src/app.ts: `schema: { hide: true }` — liveness probes
+// aren't public API); V2 ports that with `detail: { hide: true }`
+// (health.routes.ts), which is what verification/golden/openapi's
+// migrated-route gate pins /healthz to against V1's captured document.
+test('/openapi.json hides both /healthz/live and /metrics', async () => {
const { deps } = stubAppDeps();
const app = new Elysia().use(requestContext(deps)).use(opsRoutes(deps));
@@ -75,28 +80,7 @@ test('/openapi.json serves the OpenAPI document with health routes present, /met
const document = (await response.json()) as {
paths: Record<string, unknown>;
};
- const liveRoute = document.paths['/healthz/live'] as {
- get: {
- responses: {
- 200: {
- content: {
- 'application/json': {
- schema: {
- properties: Record<string, unknown>;
- required: string[];
- };
- };
- };
- };
- };
- };
- };
- const liveSchema =
- liveRoute.get.responses[200].content['application/json'].schema;
- expect(liveSchema.properties).toEqual({
- live: { const: true, type: 'boolean' },
- });
- expect(liveSchema.required).toEqual(['live']);
+ expect(document.paths['/healthz/live']).toBeUndefined();
expect(document.paths['/metrics']).toBeUndefined();
});