@rcmade/hono-docs 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +75 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -21,6 +21,8 @@
21
21
  - [Table of Contents](#table-of-contents)
22
22
  - [Install](#install)
23
23
  - [Quick Start](#quick-start)
24
+ - [⚠️ Limitations: Grouped `AppType` Not Supported](#️-limitations-grouped-apptype-not-supported)
25
+ - [✅ Supported: Individual AppType per Module](#-supported-individual-apptype-per-module)
24
26
  - [Serving the OpenAPI Docs](#serving-the-openapi-docs)
25
27
  - [Configuration](#configuration)
26
28
  - [CLI Usage](#cli-usage)
@@ -121,9 +123,75 @@ yarn add -D @rcmade/hono-docs
121
123
  export default userRoutes;
122
124
  ```
123
125
 
124
- ---
126
+ ## ⚠️ Limitations: Grouped `AppType` Not Supported
127
+
128
+ Currently, `@rcmade/hono-docs` **does not support** extracting route types from a grouped `AppType` where multiple sub-apps are composed using `.route()` or `.basePath()` on a single root app.
129
+
130
+ For example, the following pattern **is not supported**:
131
+
132
+ ```ts
133
+ import { Hono } from "hono";
134
+ import { docs } from "./docs";
135
+ import { userRoutes } from "./userRoutes";
136
+
137
+ const app = new Hono()
138
+ .basePath("/api")
139
+ .get("/", (c) => {
140
+ return c.text("Hello Hono!");
141
+ })
142
+ .route("/docs", docs)
143
+ .route("/user", userRoutes);
144
+
145
+ // ❌ This AppType is not supported
146
+ type AppType = typeof app;
147
+ ```
148
+
149
+ ### ✅ Supported: Individual AppType per Module
150
+
151
+ Instead, define and export `AppType` individually for each route module:
152
+
153
+ ```ts
154
+ // docs.ts
155
+ import { Hono } from "hono";
156
+ import { Scalar } from "hono-scalar";
157
+ import fs from "node:fs/promises";
158
+ import path from "node:path";
159
+
160
+ const docs = new Hono()
161
+ .get(
162
+ "/",
163
+ Scalar({
164
+ url: "/api/docs/open-api",
165
+ theme: "kepler",
166
+ layout: "modern",
167
+ defaultHttpClient: { targetKey: "js", clientKey: "axios" },
168
+ })
169
+ )
170
+ .get("/open-api", async (c) => {
171
+ const raw = await fs.readFile(
172
+ path.join(process.cwd(), "./openapi/openapi.json"),
173
+ "utf-8"
174
+ );
175
+ return c.json(JSON.parse(raw));
176
+ });
177
+
178
+ // ✅ This AppType is supported
179
+ export type AppType = typeof docs;
180
+ ```
181
+
182
+ ```ts
183
+ // userRoutes.ts
184
+ import { Hono } from "hono";
125
185
 
126
- 1. **Add an npm script** to `package.json`:
186
+ export const userRoutes = new Hono()
187
+ .get("/", (c) => c.json({ name: "current user" }))
188
+ .get("/u/:id", (c) => c.json({ id: c.req.param("id") }));
189
+
190
+ // ✅ This AppType is supported
191
+ export type AppType = typeof userRoutes;
192
+ ```
193
+
194
+ 3. **Add an npm script** to `package.json`:
127
195
 
128
196
  ```jsonc
129
197
  {
@@ -133,7 +201,7 @@ yarn add -D @rcmade/hono-docs
133
201
  }
134
202
  ```
135
203
 
136
- 2. **Run the CLI**:
204
+ 4. **Run the CLI**:
137
205
 
138
206
  ```bash
139
207
  npm run docs
@@ -151,6 +219,8 @@ yarn add -D @rcmade/hono-docs
151
219
  🎉 Done
152
220
  ```
153
221
 
222
+ ---
223
+
154
224
  ## Serving the OpenAPI Docs
155
225
 
156
226
  Install the viewer:
@@ -279,10 +349,10 @@ git clone [https://github.com/rcmade/hono-docs.git](https://github.com/rcmade/ho
279
349
  cd hono-docs
280
350
  pnpm install
281
351
 
282
- ````
352
+ ```
283
353
  2. Implement or modify code under `src/`.
284
354
  3. Build and watch: pnpm build --watch
285
- ````
355
+ ```
286
356
 
287
357
  4. Test locally via `npm link` or `file:` install in a demo project.
288
358
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcmade/hono-docs",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Auto-generate OpenAPI 3.0 spec from Hono route types",
5
5
  "repository": {
6
6
  "type": "git",