openvibers/openvibe.tools Commits

/openapi.json redirects to the gateway's own document (SEO-3) (#207)

OP OpenVibers committed 10 days ago · 112eed015e · 2 files, +5 −0

Agents look for /openapi.json first; it answered 404 while the document is at
/api/v1/openapi.json (and agent.json names it there).

Changes

ddiff --git a/apps/gateway/server/index.js b/apps/gateway/server/index.js
iindex e2b4870..15bbd41 100644
---- a/apps/gateway/server/index.js
++++ b/apps/gateway/server/index.js
@@@ -34,6 +34,8 @@ const { createGuard, TRUST_PROXY } = require('../../_shared/guard');
const { createNetworkSender } = require('openvibe-sdk/account-data'); // ADR-033: Tools' part of an export, back to Network
const app = express();
++// SEO-3: /openapi.json, where agents look first, is the gateway's own document (server/openapi.js).
++app.get('/openapi.json', (req, res) => res.redirect(308, '/api/v1/openapi.json'));
// Network's sign-out-everywhere cutoffs for every Tools app (./revocation-events.js): before any body parser.
app.post('/internal/events', ...require('./revocation-events').handler());
// What this deploy runs (ADR-016); the shared navbar's release-watch polls it on every tool host.
ddiff --git a/apps/gateway/test/openapi.test.js b/apps/gateway/test/openapi.test.js
iindex aa088b1..e7de8d8 100644
---- a/apps/gateway/test/openapi.test.js
++++ b/apps/gateway/test/openapi.test.js
@@@ -20,4 +20,7 @@ assert.strictEqual(ids.length, new Set(ids).size, 'operation ids are unique');
assert.ok(doc.paths['/api/v1/tools'] && doc.paths['/api/v1/jobs/{id}/events'], 'registry and jobs facade are documented');
const json = doc.paths['/api/v1/tools/jsonminify/run'].post.requestBody.content['application/json'];
assert.deepStrictEqual(json.schema.properties.input.required, ['text'], 'the tool input schema is inline');
++// SEO-3: /openapi.json, where agents look first, redirects to this document.
++const src = require('fs').readFileSync(require('path').join(__dirname, '..', 'server', 'index.js'), 'utf8');
++assert.match(src, /app\.get\('\/openapi\.json', \(req, res\) => res\.redirect\(308, '\/api\/v1\/openapi\.json'\)\);/);
console.log(`openapi: ${withApi.length} run paths, all checks passed`);