Files
OpenIsle/docs/lib/media-adapter.ts
2025-09-18 14:42:25 +08:00

24 lines
579 B
TypeScript

import type { MediaAdapter } from "fumadocs-openapi";
export const OpenIsleMediaAdapter: MediaAdapter = {
encode(data) {
return JSON.stringify(data.body);
},
// returns code that inits a `body` variable, used for request body
generateExample(data, ctx) {
if (ctx.lang === "js") {
return `const body = "hello world"`;
}
if (ctx.lang === "python") {
return `body = "hello world"`;
}
if (ctx.lang === "go" && "addImport" in ctx) {
ctx.addImport("strings");
return `body := strings.NewReader("hello world")`;
}
},
};