mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-18 13:01:02 +08:00
24 lines
579 B
TypeScript
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")`;
|
|
}
|
|
},
|
|
};
|