UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

33 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SchemaApi = void 0; const MiscUtils_1 = require("../utils/MiscUtils"); /** * API endpoints for serving OpenAPI schema documentation. */ class SchemaApi { constructor(yamlSchema = SchemaApi.DEFAULT_YAML_SCHEMA, htmlSchema = SchemaApi.DEFAULT_HTML_SCHEMA) { this.yamlSchema = yamlSchema; this.htmlSchema = htmlSchema; } /** * Serves the OpenAPI schema in YAML or HTML format based on Accept header. * Defaults to YAML if no specific format is requested. */ async getSchema(req, res) { const acceptHeader = req.headers.accept || ''; const prefersHtml = acceptHeader.includes('text/html'); if (prefersHtml) { res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.send(this.htmlSchema); } else { res.setHeader('Content-Type', 'application/yaml; charset=utf-8'); res.send(this.yamlSchema); } } } exports.SchemaApi = SchemaApi; SchemaApi.DEFAULT_YAML_SCHEMA = MiscUtils_1.MiscUtils.getResourceFileAsString('openapi-schema.yaml'); SchemaApi.DEFAULT_HTML_SCHEMA = MiscUtils_1.MiscUtils.getResourceFileAsString('openapi-schema.html'); //# sourceMappingURL=SchemaApi.js.map