Skip to content

Commit 86be21e

Browse files
committed
manually patch openapi.json
1 parent 483f9af commit 86be21e

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

nitro.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,27 @@ export default defineNitroConfig({
3535
experimental: {
3636
openAPI: true,
3737
},
38+
hooks: {
39+
"prerender:generate"(entry) {
40+
if (/scalar|swagger/.test(entry.route)) {
41+
return (entry.skip = true);
42+
}
43+
if (entry.route === "/_openapi.json") {
44+
const json = JSON.parse(entry.contents);
45+
json.servers = [{ url: "https://ungh.cc" }];
46+
for (const key in json.paths) {
47+
if (json.paths[key].get?.tags?.includes("Internal")) {
48+
delete json.paths[key];
49+
} else {
50+
json.paths[key].get.tags = [];
51+
}
52+
}
53+
entry.contents = JSON.stringify(json, undefined, 2);
54+
}
55+
},
56+
},
3857
openAPI: {
39-
production: "runtime",
58+
production: "prerender",
4059
meta: {
4160
title: "🐙 ungh.cc",
4261
description: `Unlimited access to GitHub API. <br><br> ⭐ [Star on GitHub](https://github.com/unjs/ungh) <br> 💛 Hosting sponsored by [Vercel](https://vercel.com/?utm_source=ungh)`,

0 commit comments

Comments
 (0)