Skip to content

Commit 70555b8

Browse files
committed
enable open api
1 parent ab26692 commit 70555b8

4 files changed

Lines changed: 35 additions & 13 deletions

File tree

β€Žnitro.config.tsβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,15 @@ export default defineNitroConfig({
3232
base: "./.cache/gh",
3333
},
3434
},
35+
experimental: {
36+
openAPI: true,
37+
},
38+
openAPI: {
39+
production: "runtime",
40+
meta: {
41+
title: "πŸ™ Ungh",
42+
description: "Unlimited access to GitHub API",
43+
version: "1.0.0",
44+
},
45+
},
3546
});

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"eslint": "^9.31.0",
1717
"eslint-config-unjs": "^0.5.0",
1818
"nitropack": "^2.12.4",
19+
"openapi-renderer": "^0.1.1",
1920
"prettier": "^3.6.2",
2021
"std-env": "^3.9.0",
2122
"typescript": "^5.8.3"

β€Žpnpm-lock.yamlβ€Ž

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žroutes/index.tsβ€Ž

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
const url = "https://github.com/unjs/ungh";
1+
import { renderHTML } from "openapi-renderer";
22

33
export default eventHandler(
4-
() => `<!DOCTYPE html>
5-
<html>
6-
<head>
7-
<title>πŸ™ UNGH API</title>
8-
<meta charset="utf-8">
9-
</head>
10-
<body>
11-
<h1>πŸ™ UNGH API</h1>
12-
13-
<br>
14-
Learn more: <a href="${url}">${url}</a>
15-
`,
4+
() =>
5+
renderHTML({
6+
renderer: "scalar",
7+
spec: "/_openapi.json",
8+
}) +
9+
/* html */ `<script> if (window.location.hash === '') { window.location.hash = '#tag/app-routes'; } </script>`,
1610
);

0 commit comments

Comments
Β (0)