mcp-openapi-schema-explorer
Version:
MCP OpenAPI schema explorer
52 lines • 1.16 kB
JavaScript
import { dump as yamlDump } from 'js-yaml';
/**
* JSON formatter with pretty printing
*/
export class JsonFormatter {
format(data) {
return JSON.stringify(data, null, 2);
}
getMimeType() {
return 'application/json';
}
}
/**
* Formats data as minified JSON.
*/
export class MinifiedJsonFormatter {
format(data) {
return JSON.stringify(data);
}
getMimeType() {
return 'application/json';
}
}
/**
* YAML formatter using js-yaml library
*/
export class YamlFormatter {
format(data) {
return yamlDump(data, {
indent: 2,
lineWidth: -1, // Don't wrap long lines
noRefs: true, // Don't use references
});
}
getMimeType() {
return 'text/yaml';
}
}
/**
* Creates a formatter instance based on format name
*/
export function createFormatter(format) {
switch (format) {
case 'json':
return new JsonFormatter();
case 'yaml':
return new YamlFormatter();
case 'json-minified':
return new MinifiedJsonFormatter();
}
}
//# sourceMappingURL=formatters.js.map