@yaakdoc/snippets
v0.6.0
Published
Code example generators (cURL, fetch, Python, Go, grpcurl, wscat) for yaakdoc.
Maintainers
Readme
@yaakdoc/snippets
Code example generators for yaakdoc: curl, javascript, python, go, grpcurl and wscat.
// snippets/httpie.ts
import { applyAuth } from "@yaakdoc/core";
import { defineSnippet } from "@yaakdoc/snippets";
export default defineSnippet({
id: "httpie",
label: "HTTPie",
language: "bash",
supports: ["http"],
generate(request) {
if (request.kind !== "http") {
return "";
}
const req = applyAuth(request);
return [`http ${req.method} '${req.url}'`, ...req.headers.map((h) => `'${h.name}:${h.value}'`)].join(" \\\n ");
},
});{
"snippets": ["curl", "./snippets/httpie.ts", "python"]
}See Code examples for the built-in generators and what they support.
