lokicms-plugin-api-docs 1.0.0 → 1.1.0
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.
- package/README.md +181 -66
- package/dist/formatters/openapi-formatter.d.ts +1 -1
- package/dist/formatters/openapi-formatter.js +207 -299
- package/dist/formatters/openapi-formatter.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +186 -171
- package/dist/plugin.js.map +1 -1
- package/dist/services/doc-generator.d.ts +5 -5
- package/dist/services/doc-generator.d.ts.map +1 -1
- package/dist/services/doc-generator.js +92 -230
- package/dist/services/doc-generator.js.map +1 -1
- package/dist/services/rest-api-definitions.d.ts +19 -0
- package/dist/services/rest-api-definitions.d.ts.map +1 -0
- package/dist/services/rest-api-definitions.js +1311 -0
- package/dist/services/rest-api-definitions.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# lokicms-plugin-api-docs
|
|
2
2
|
|
|
3
|
-
API documentation generator for LokiCMS with OpenAPI, Markdown, and TypeScript
|
|
3
|
+
REST API documentation generator for LokiCMS with OpenAPI 3.0, Markdown, and TypeScript support.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
7
|
+
- **Complete REST API Documentation**: Documents all LokiCMS REST endpoints (auth, entries, content-types, media, etc.)
|
|
8
8
|
- **Multiple Output Formats**: JSON, Markdown, OpenAPI 3.0, TypeScript interfaces
|
|
9
|
-
- **
|
|
9
|
+
- **Content Type Schemas**: Generates documentation for registered content types
|
|
10
|
+
- **Filtering**: Filter endpoints by tag, HTTP method, or search term
|
|
10
11
|
- **5 MCP Tools**: Full control via Model Context Protocol
|
|
11
12
|
|
|
12
13
|
## Installation
|
|
@@ -25,8 +26,8 @@ const cms = createLokiCMS({
|
|
|
25
26
|
apiDocs: {
|
|
26
27
|
title: 'My API',
|
|
27
28
|
version: '1.0.0',
|
|
28
|
-
description: 'API documentation for my LokiCMS project',
|
|
29
|
-
baseUrl: '
|
|
29
|
+
description: 'REST API documentation for my LokiCMS project',
|
|
30
|
+
baseUrl: 'https://api.example.com',
|
|
30
31
|
includeExamples: true,
|
|
31
32
|
},
|
|
32
33
|
});
|
|
@@ -36,134 +37,220 @@ const cms = createLokiCMS({
|
|
|
36
37
|
|
|
37
38
|
| Tool | Description |
|
|
38
39
|
|------|-------------|
|
|
39
|
-
| `docs_generate` | Generate complete API documentation
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
40
|
+
| `docs_generate` | Generate complete REST API documentation |
|
|
41
|
+
| `docs_endpoints` | List endpoints with filtering by tag, method, or search |
|
|
42
|
+
| `docs_tags` | List all API categories/tags |
|
|
43
|
+
| `docs_content_types` | Document content types and their field schemas |
|
|
42
44
|
| `docs_export` | Export documentation to a file |
|
|
43
|
-
| `docs_endpoints` | Generate REST-like endpoint documentation |
|
|
44
45
|
|
|
45
46
|
### docs_generate
|
|
46
47
|
|
|
47
|
-
Generate complete API documentation.
|
|
48
|
+
Generate complete REST API documentation.
|
|
48
49
|
|
|
49
50
|
```json
|
|
50
51
|
{
|
|
51
52
|
"format": "openapi",
|
|
52
|
-
"
|
|
53
|
+
"tags": ["Authentication", "Entries"],
|
|
53
54
|
"includeContentTypes": true,
|
|
54
55
|
"includeExamples": true,
|
|
55
56
|
"baseUrl": "https://api.example.com"
|
|
56
57
|
}
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
**Output formats:**
|
|
61
|
+
- `json` - Raw structured JSON
|
|
62
|
+
- `markdown` - Human-readable documentation
|
|
63
|
+
- `openapi` - OpenAPI 3.0 specification
|
|
64
|
+
- `typescript` - TypeScript interfaces
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
### docs_endpoints
|
|
67
|
+
|
|
68
|
+
List REST API endpoints with filtering.
|
|
62
69
|
|
|
63
70
|
```json
|
|
64
71
|
{
|
|
65
|
-
"format": "
|
|
66
|
-
"
|
|
67
|
-
"
|
|
72
|
+
"format": "json",
|
|
73
|
+
"tag": "Entries",
|
|
74
|
+
"method": "GET",
|
|
75
|
+
"search": "publish"
|
|
68
76
|
}
|
|
69
77
|
```
|
|
70
78
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Document content types.
|
|
74
|
-
|
|
79
|
+
**Response:**
|
|
75
80
|
```json
|
|
76
81
|
{
|
|
77
|
-
"
|
|
78
|
-
"
|
|
82
|
+
"success": true,
|
|
83
|
+
"count": 12,
|
|
84
|
+
"endpoints": [
|
|
85
|
+
{
|
|
86
|
+
"method": "GET",
|
|
87
|
+
"path": "/api/entries",
|
|
88
|
+
"summary": "List entries",
|
|
89
|
+
"requiresAuth": false,
|
|
90
|
+
"tags": ["Entries"]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
79
93
|
}
|
|
80
94
|
```
|
|
81
95
|
|
|
82
|
-
###
|
|
96
|
+
### docs_tags
|
|
83
97
|
|
|
84
|
-
|
|
98
|
+
List all available API tags/categories.
|
|
85
99
|
|
|
86
100
|
```json
|
|
87
101
|
{
|
|
88
|
-
"
|
|
89
|
-
"outputPath": "./docs/api.json"
|
|
102
|
+
"includeEndpointCounts": true
|
|
90
103
|
}
|
|
91
104
|
```
|
|
92
105
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Generate endpoint documentation.
|
|
96
|
-
|
|
106
|
+
**Response:**
|
|
97
107
|
```json
|
|
98
108
|
{
|
|
99
|
-
"
|
|
100
|
-
"
|
|
109
|
+
"success": true,
|
|
110
|
+
"tags": [
|
|
111
|
+
{ "tag": "Authentication", "endpointCount": 8 },
|
|
112
|
+
{ "tag": "Entries", "endpointCount": 12 },
|
|
113
|
+
{ "tag": "Media", "endpointCount": 8 }
|
|
114
|
+
]
|
|
101
115
|
}
|
|
102
116
|
```
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
### docs_content_types
|
|
105
119
|
|
|
106
|
-
|
|
120
|
+
Document content types and their schemas.
|
|
107
121
|
|
|
108
|
-
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"format": "typescript",
|
|
125
|
+
"filter": "product"
|
|
126
|
+
}
|
|
127
|
+
```
|
|
109
128
|
|
|
110
|
-
###
|
|
129
|
+
### docs_export
|
|
111
130
|
|
|
112
|
-
|
|
131
|
+
Export documentation to a file.
|
|
113
132
|
|
|
114
|
-
```
|
|
115
|
-
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"format": "openapi",
|
|
136
|
+
"outputPath": "./docs/openapi.json",
|
|
137
|
+
"baseUrl": "https://api.example.com"
|
|
138
|
+
}
|
|
139
|
+
```
|
|
116
140
|
|
|
117
|
-
##
|
|
141
|
+
## API Coverage
|
|
118
142
|
|
|
119
|
-
|
|
120
|
-
Create a new credential
|
|
143
|
+
This plugin documents all LokiCMS REST API endpoints:
|
|
121
144
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
|
126
|
-
|
|
127
|
-
|
|
145
|
+
| Category | Endpoints |
|
|
146
|
+
|----------|-----------|
|
|
147
|
+
| Authentication | Login, register, refresh token, API keys |
|
|
148
|
+
| Content Types | CRUD operations, field management |
|
|
149
|
+
| Entries | CRUD, publish/unpublish, archive, terms |
|
|
150
|
+
| Search | Global search, suggestions, content type search |
|
|
151
|
+
| Media | Upload, list, update, delete, serve files |
|
|
152
|
+
| Taxonomies | Category/tag system management |
|
|
153
|
+
| Terms | Individual taxonomy term management |
|
|
154
|
+
| Users | User account management |
|
|
155
|
+
| GraphQL | GraphQL endpoint documentation |
|
|
156
|
+
| Utility | Health check, plugin list |
|
|
128
157
|
|
|
129
|
-
|
|
158
|
+
## Output Examples
|
|
130
159
|
|
|
131
|
-
|
|
160
|
+
### OpenAPI 3.0
|
|
132
161
|
|
|
133
162
|
```json
|
|
134
163
|
{
|
|
135
164
|
"openapi": "3.0.0",
|
|
136
165
|
"info": {
|
|
137
|
-
"title": "
|
|
166
|
+
"title": "LokiCMS REST API",
|
|
138
167
|
"version": "1.0.0"
|
|
139
168
|
},
|
|
140
169
|
"paths": {
|
|
141
|
-
"/
|
|
170
|
+
"/api/auth/login": {
|
|
142
171
|
"post": {
|
|
143
|
-
"summary": "
|
|
144
|
-
|
|
172
|
+
"summary": "Login with credentials",
|
|
173
|
+
"tags": ["Authentication"],
|
|
174
|
+
"requestBody": {
|
|
175
|
+
"content": {
|
|
176
|
+
"application/json": {
|
|
177
|
+
"schema": {
|
|
178
|
+
"type": "object",
|
|
179
|
+
"properties": {
|
|
180
|
+
"email": { "type": "string", "format": "email" },
|
|
181
|
+
"password": { "type": "string" }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"/api/entries": {
|
|
190
|
+
"get": {
|
|
191
|
+
"summary": "List entries",
|
|
192
|
+
"parameters": [
|
|
193
|
+
{ "name": "contentType", "in": "query" },
|
|
194
|
+
{ "name": "status", "in": "query" }
|
|
195
|
+
]
|
|
145
196
|
}
|
|
146
197
|
}
|
|
198
|
+
},
|
|
199
|
+
"components": {
|
|
200
|
+
"securitySchemes": {
|
|
201
|
+
"bearerAuth": { "type": "http", "scheme": "bearer" },
|
|
202
|
+
"apiKey": { "type": "apiKey", "in": "header", "name": "X-API-Key" }
|
|
203
|
+
}
|
|
147
204
|
}
|
|
148
205
|
}
|
|
149
206
|
```
|
|
150
207
|
|
|
151
|
-
###
|
|
208
|
+
### Markdown
|
|
152
209
|
|
|
153
|
-
|
|
210
|
+
```markdown
|
|
211
|
+
# LokiCMS REST API
|
|
212
|
+
|
|
213
|
+
## Authentication
|
|
214
|
+
|
|
215
|
+
### `POST` /api/auth/login
|
|
216
|
+
Login with credentials. Returns JWT tokens.
|
|
217
|
+
|
|
218
|
+
**Request Body:**
|
|
219
|
+
| Field | Type | Required | Description |
|
|
220
|
+
|-------|------|----------|-------------|
|
|
221
|
+
| email | string | Yes | User email |
|
|
222
|
+
| password | string | Yes | Password |
|
|
223
|
+
|
|
224
|
+
### `GET` /api/auth/me
|
|
225
|
+
Get current user profile and permissions.
|
|
226
|
+
|
|
227
|
+
## Entries
|
|
228
|
+
|
|
229
|
+
### `GET` /api/entries
|
|
230
|
+
List entries with filtering and pagination.
|
|
231
|
+
...
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### TypeScript
|
|
154
235
|
|
|
155
236
|
```typescript
|
|
156
237
|
/**
|
|
157
|
-
*
|
|
238
|
+
* Entry content object
|
|
158
239
|
*/
|
|
159
|
-
export interface
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
240
|
+
export interface ProductEntry {
|
|
241
|
+
id: string;
|
|
242
|
+
contentTypeId: string;
|
|
243
|
+
contentTypeSlug: string;
|
|
244
|
+
slug: string;
|
|
245
|
+
title: string;
|
|
246
|
+
status: 'draft' | 'published' | 'scheduled' | 'archived';
|
|
247
|
+
data: {
|
|
248
|
+
name: string;
|
|
249
|
+
price: number;
|
|
250
|
+
description?: string;
|
|
251
|
+
};
|
|
252
|
+
createdAt: number;
|
|
253
|
+
updatedAt: number;
|
|
167
254
|
}
|
|
168
255
|
```
|
|
169
256
|
|
|
@@ -181,7 +268,6 @@ const docGen = getDocGenerator();
|
|
|
181
268
|
|
|
182
269
|
// Generate documentation
|
|
183
270
|
const docs = await docGen.generate({
|
|
184
|
-
includeTools: true,
|
|
185
271
|
includeContentTypes: true,
|
|
186
272
|
includeExamples: true,
|
|
187
273
|
});
|
|
@@ -194,6 +280,12 @@ const openApiSpec = formatAsOpenApi(docs, {
|
|
|
194
280
|
// Generate TypeScript interfaces
|
|
195
281
|
const tsOutput = generateTypeScript(docs);
|
|
196
282
|
console.log(tsOutput.code);
|
|
283
|
+
|
|
284
|
+
// Get endpoints by tag
|
|
285
|
+
const authEndpoints = docGen.getEndpoints('Authentication');
|
|
286
|
+
|
|
287
|
+
// Get all tags
|
|
288
|
+
const tags = docGen.getTags();
|
|
197
289
|
```
|
|
198
290
|
|
|
199
291
|
## Configuration
|
|
@@ -215,6 +307,29 @@ interface ApiDocsConfig {
|
|
|
215
307
|
}
|
|
216
308
|
```
|
|
217
309
|
|
|
310
|
+
## Frontend Integration
|
|
311
|
+
|
|
312
|
+
Use the generated OpenAPI spec or TypeScript types for frontend development:
|
|
313
|
+
|
|
314
|
+
1. **Export OpenAPI spec:**
|
|
315
|
+
```json
|
|
316
|
+
{ "format": "openapi", "outputPath": "./docs/api.json" }
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
2. **Generate TypeScript client:**
|
|
320
|
+
```bash
|
|
321
|
+
npx openapi-typescript ./docs/api.json -o ./src/api-types.ts
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
3. **Use with fetch/axios:**
|
|
325
|
+
```typescript
|
|
326
|
+
import type { ProductEntry } from './api-types';
|
|
327
|
+
|
|
328
|
+
const response = await fetch('https://api.example.com/api/entries?contentType=product');
|
|
329
|
+
const data = await response.json();
|
|
330
|
+
const products: ProductEntry[] = data.entries;
|
|
331
|
+
```
|
|
332
|
+
|
|
218
333
|
## License
|
|
219
334
|
|
|
220
335
|
MIT
|