API Documentation Generator Skill for GitHub Copilot

API Documentation Generator Skill for GitHub Copilot

Generates structured Markdown API reference docs from source code, OpenAPI specs or route definitions, as one file or one per endpoint.

Skill files1 file
SKILL.md289 lines
1
---
2
name: api-docs-generator
3
description: Generate structured API reference documentation from source code, OpenAPI specs, or route definitions. Trigger phrases include "generate API docs", "document this API", "create API reference", "write endpoint docs", "scaffold API docs".
4
---
5
6
# API Documentation Generator
7
8
Generate clean, structured Markdown API reference docs from source code, OpenAPI/Swagger specs, or route definitions.
9
10
## Gather Context
11
12
Before writing anything, determine:
13
14
1. **Source** — Controller, route file, OpenAPI spec (JSON/YAML), or a set of files?
15
2. **API name** — e.g., "User Management API". Infer from class/file name if not stated.
16
3. **Base URL** — e.g., `https://api.example.com/v1`. Default to `https://api.example.com` if unknown.
17
4. **Auth method** — Bearer token (default), API key, OAuth 2.0, or none.
18
5. **Output format**:
19
- `single-file` (default) — one Markdown file with all endpoints
20
- `per-endpoint` — one file per endpoint (`{method}-{path-slug}.md`) plus a `README.md` index
21
6. **Language/framework** — Auto-detect from file extensions, imports, and decorators.
22
23
**If context is missing:** In conversational mode, ask. In agent/inline mode, use sensible defaults and note your assumptions at the top of the output.
24
25
## Analyzing the Source
26
27
### From Source Code
28
29
Read the file(s) and extract:
30
31
- Every endpoint: HTTP method + route path
32
- Route params, query params, request body schemas
33
- Response types, status codes, and return models
34
- Auth requirements (per-endpoint if they vary)
35
- Doc comments, decorators, or annotations (`/// <summary>`, `@ApiOperation`, `@app.get(...)`, JSDoc `@param`/`@returns`, etc.)
36
37
**Framework detection hints:**
38
39
| Signal | Framework |
40
|--------|-----------|
41
| `[ApiController]`, `[HttpGet]` | ASP.NET Core |
42
| `@app.get()`, `@router.post()` | FastAPI |
43
| `router.get()`, `app.use()` | Express.js |
44
| `@GetMapping`, `@RestController` | Spring Boot |
45
| `@Controller`, `@Get()` | NestJS |
46
| `resources :users` | Rails |
47
48
### From OpenAPI/Swagger Specs
49
50
Parse the spec and map directly:
51
52
- `paths` → endpoints
53
- `parameters` → params table
54
- `requestBody` → request body section
55
- `responses` → response table + examples
56
- `components/schemas` → inline the referenced models
57
- `securityDefinitions` / `securitySchemes` → auth section
58
- `info.title`, `info.version`, `servers[0].url` → header metadata
59
60
Prefer descriptions from the spec. Only infer descriptions when the spec omits them.
61
62
### Handling Incomplete Source
63
64
If the source references models, DTOs, or types defined in other files:
65
66
- Document what's visible. Use the type name as-is (e.g., `UserDto`) and note that the full schema is defined elsewhere.
67
- If the user provides multiple files, cross-reference them to build complete schemas.
68
- Never fabricate fields for a model you can't see.
69
70
## Documentation Template
71
72
````markdown
73
# {API Name} — API Reference
74
75
> Base URL: `{base-url}`
76
> Authentication: {auth-method}
77
> Version: {version}
78
79
## Table of Contents
80
81
- [Authentication](#authentication)
82
- [{Resource Group}](#{resource-group-slug})
83
- [{METHOD} {path}](#{endpoint-anchor})
84
85
## Authentication
86
87
{How to authenticate: header format, token acquisition, expiration/refresh if known.}
88
89
**Header format:**
90
91
```
92
Authorization: Bearer {token}
93
```
94
95
---
96
97
## {Resource Group}
98
99
### {METHOD} `{path}`
100
101
{One-line description from doc comments or inferred from the code.}
102
103
**Parameters**
104
105
| Name | In | Type | Required | Description |
106
|------|----|------|----------|-------------|
107
| `id` | path | integer | ✅ | Resource ID |
108
| `limit` | query | integer | ❌ | Max results (default: 20) |
109
110
**Request Body** *(POST/PUT/PATCH only)*
111
112
```json
113
{
114
"email": "string — the user's email address",
115
"displayName": "string — display name"
116
}
117
```
118
119
**Responses**
120
121
| Status | Description |
122
|--------|-------------|
123
| `200 OK` | Returns the resource |
124
| `404 Not Found` | Resource not found |
125
126
```json
127
{
128
"id": 42,
129
"email": "jane@example.com",
130
"displayName": "Jane Smith",
131
"createdAt": "2026-01-15T10:30:00Z"
132
}
133
```
134
135
**Example**
136
137
```bash
138
curl -X GET "{base-url}/{path}" \
139
-H "Authorization: Bearer eyJhbG..."
140
```
141
````
142
143
For `per-endpoint` format: one file per endpoint named `{method}-{path-slug}.md` (e.g., `get-users-id.md`), each using the endpoint section above, plus a `README.md` that links to all of them grouped by resource.
144
145
## Common API Patterns to Document
146
147
When you encounter these in the source, document them:
148
149
- **Pagination** — query params like `page`, `limit`, `offset`, `cursor`. Note defaults and max values if visible.
150
- **Filtering/sorting** — query params like `sort`, `filter`, `q`, `status`. Document allowed values.
151
- **Rate limiting** — if headers like `X-RateLimit-*` or decorators like `@Throttle()` are present, add a "Rate Limiting" section.
152
- **Versioning** — if the API uses path versioning (`/v1/`, `/v2/`) or header versioning, note it in the header.
153
- **Bulk operations** — endpoints accepting arrays or batch payloads.
154
155
## Rules
156
157
**Do:**
158
159
- Extract only what exists in the source — never invent endpoints, params, or fields
160
- Use exact route paths, param names, and types from the code
161
- Preserve existing descriptions from doc comments, annotations, or spec descriptions
162
- Include a `curl` example for every endpoint
163
- Use realistic fake data in examples (`jane@example.com`, `42`, `"acme-corp"` — not `"string"` or `"value"`)
164
- Document both success and error responses
165
- Use standard HTTP status descriptions (200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, etc.)
166
- Flag ambiguity with a note (e.g., *"Response schema inferred from return type; actual response may differ"*)
167
168
**Don't:**
169
170
- Invent endpoints or params that aren't in the source
171
- Use placeholder junk like `"string"`, `"value"`, or `"example"` in response bodies
172
- Skip error responses — include at least 400 and 404 where applicable
173
- Assume auth requirements if the code doesn't specify them — note the uncertainty instead
174
175
## Example
176
177
**Input** — ASP.NET Core controller:
178
179
```csharp
180
[ApiController]
181
[Route("api/[controller]")]
182
public class UsersController : ControllerBase
183
{
184
/// <summary>Gets a user by their ID.</summary>
185
[HttpGet("{id}")]
186
public async Task<ActionResult<UserDto>> GetUser(int id) { }
187
188
/// <summary>Creates a new user.</summary>
189
[HttpPost]
190
public async Task<ActionResult<UserDto>> CreateUser([FromBody] CreateUserRequest request) { }
191
}
192
```
193
194
**Output:**
195
196
````markdown
197
# Users API — API Reference
198
199
> Base URL: `https://api.example.com`
200
> Authentication: Bearer token
201
202
## Users
203
204
### GET `/api/users/{id}`
205
206
Gets a user by their ID.
207
208
**Parameters**
209
210
| Name | In | Type | Required | Description |
211
|------|----|------|----------|-------------|
212
| `id` | path | integer | ✅ | The user's unique ID |
213
214
**Responses**
215
216
| Status | Description |
217
|--------|-------------|
218
| `200 OK` | Returns the user |
219
| `404 Not Found` | User not found |
220
221
```json
222
{
223
"id": 42,
224
"email": "jane@example.com",
225
"displayName": "Jane Smith",
226
"createdAt": "2026-01-15T10:30:00Z"
227
}
228
```
229
230
**Example**
231
232
```bash
233
curl -X GET "https://api.example.com/api/users/42" \
234
-H "Authorization: Bearer eyJhbG..."
235
```
236
237
---
238
239
### POST `/api/users`
240
241
Creates a new user.
242
243
**Request Body**
244
245
```json
246
{
247
"email": "string — the user's email address",
248
"displayName": "string — the user's display name",
249
"role": "string — user role (admin, member, viewer)"
250
}
251
```
252
253
**Responses**
254
255
| Status | Description |
256
|--------|-------------|
257
| `201 Created` | User created successfully |
258
| `400 Bad Request` | Invalid request body |
259
| `409 Conflict` | Email already exists |
260
261
```json
262
{
263
"id": 43,
264
"email": "john@example.com",
265
"displayName": "John Doe",
266
"createdAt": "2026-02-18T14:00:00Z"
267
}
268
```
269
270
**Example**
271
272
```bash
273
curl -X POST "https://api.example.com/api/users" \
274
-H "Authorization: Bearer eyJhbG..." \
275
-H "Content-Type: application/json" \
276
-d '{"email": "john@example.com", "displayName": "John Doe", "role": "member"}'
277
```
278
````
279
280
## Pre-Delivery Checklist
281
282
- [ ] Every endpoint in the source is documented — none missing, none invented
283
- [ ] All params have correct name, location (`path`/`query`/`header`/`body`), type, and required status
284
- [ ] Every endpoint has a `curl` example with realistic data
285
- [ ] Response examples use plausible fake data, not placeholders
286
- [ ] Endpoints are grouped by resource and sorted GET → POST → PUT → PATCH → DELETE
287
- [ ] Auth section matches what the code actually specifies
288
- [ ] Ambiguities are flagged, not silently assumed
289
- [ ] TOC anchors resolve correctly

© Microsoft 365 & Power Platform Community · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…