@@ -316,6 +316,48 @@ To extend API documentation:
3163164 . Include error response schemas (400, 401, 500, etc.)
3173175 . Add parameter validation schemas
318318
319+ ## Plugin API Routes
320+
321+ ### Plugin Route Structure
322+
323+ All plugin routes are automatically namespaced under ` /api/plugin/<plugin-name>/ ` for security and isolation:
324+
325+ - ** Core Routes** : ` /api/auth/* ` , ` /api/users/* ` , ` /api/settings/* ` (protected from plugins)
326+ - ** Plugin Routes** : ` /api/plugin/<plugin-name>/* ` (isolated per plugin)
327+
328+ ### Example Plugin Routes
329+
330+ For a plugin with ID ` example-plugin ` :
331+
332+ ```
333+ GET /api/plugin/example-plugin/examples
334+ GET /api/plugin/example-plugin/examples/:id
335+ POST /api/plugin/example-plugin/examples
336+ PUT /api/plugin/example-plugin/examples/:id
337+ DELETE /api/plugin/example-plugin/examples/:id
338+ ```
339+
340+ ### Security Benefits
341+
342+ 1 . ** Route Isolation** : Plugins cannot interfere with core routes or each other
343+ 2 . ** Predictable Structure** : All plugin APIs follow the same pattern
344+ 3 . ** Easy Identification** : Plugin ownership is clear from the URL
345+ 4 . ** Automatic Namespacing** : No manual prefix management required
346+
347+ ### Plugin Route Registration
348+
349+ Plugins register routes using the ` PluginRouteManager ` :
350+
351+ ``` typescript
352+ // In plugin's routes.ts file
353+ export async function registerRoutes(routeManager : PluginRouteManager , db : AnyDatabase | null ) {
354+ // This becomes /api/plugin/my-plugin/data
355+ routeManager .get (' /data' , async () => {
356+ return { message: ' Hello from plugin!' };
357+ });
358+ }
359+ ```
360+
319361## Files Generated
320362
321363- ` api-spec.json ` - Complete OpenAPI 3.0 specification in JSON format
0 commit comments