digiqagent 1.2.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/.cursor-plugin/plugin.json +29 -0
- package/README.md +197 -0
- package/agents/code-reviewer.md +48 -0
- package/bin/cli.js +210 -0
- package/package.json +41 -0
- package/skills/playwright-test-generator/SKILL.md +563 -0
- package/skills/playwright-test-generator/interaction-test-patterns.md +987 -0
- package/skills/playwright-test-generator/page-object-patterns.md +833 -0
- package/skills/postman-collection-generator/SKILL.md +310 -0
- package/skills/postman-collection-generator/collection-patterns.md +493 -0
- package/skills/postman-test-suite-generator/SKILL.md +653 -0
- package/skills/postman-test-suite-generator/test-scenario-patterns.md +612 -0
- package/skills/receiving-code-review/SKILL.md +213 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +146 -0
- package/skills/review-prompts/code-quality-reviewer-prompt.md +26 -0
- package/skills/review-prompts/spec-reviewer-prompt.md +61 -0
- package/skills/swagger-generator/SKILL.md +238 -0
- package/skills/swagger-generator/openapi-patterns.md +667 -0
- package/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/skills/systematic-debugging/SKILL.md +296 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/test-academic.md +14 -0
- package/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/skills/test-driven-development/SKILL.md +371 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/verification-before-completion/SKILL.md +139 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swagger-generator
|
|
3
|
+
description: Use when generating or updating OpenAPI/Swagger specs from codebase routes, controllers, models, or from an API design document
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Swagger / OpenAPI Specification Generator
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Produce a complete, valid OpenAPI 3.0 specification from the project's source code **or** a provided API design document. The output is a ready-to-use `openapi.yaml` (or `swagger.yaml`) file.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Every endpoint, every parameter, every response code — documented. If it exists in code, it exists in the spec.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- New API project needs documentation
|
|
17
|
+
- Existing API has no spec or an outdated spec
|
|
18
|
+
- API design document needs to be formalized into OpenAPI
|
|
19
|
+
- Before generating Postman collections (prerequisite for `digiqagent:postman-collection-generator`)
|
|
20
|
+
|
|
21
|
+
## Input Detection
|
|
22
|
+
|
|
23
|
+
Determine the source **before** starting generation:
|
|
24
|
+
|
|
25
|
+
### Source A — Codebase Analysis
|
|
26
|
+
|
|
27
|
+
Scan the project to detect the framework:
|
|
28
|
+
|
|
29
|
+
| Framework | Look For |
|
|
30
|
+
|-----------|----------|
|
|
31
|
+
| **Express** | `app.get/post/put/delete`, `router.*`, route files |
|
|
32
|
+
| **NestJS** | `@Controller`, `@Get/@Post/@Put/@Delete` decorators |
|
|
33
|
+
| **FastAPI** | `@app.get/post`, `@router.*`, Pydantic models |
|
|
34
|
+
| **Spring Boot** | `@RestController`, `@RequestMapping`, `@GetMapping` |
|
|
35
|
+
| **Django REST** | `ViewSet`, `@api_view`, `urlpatterns` |
|
|
36
|
+
| **Go (Gin/Echo)** | `r.GET/POST`, `e.GET/POST`, handler functions |
|
|
37
|
+
| **Rails** | `routes.rb`, `resources :`, controller actions |
|
|
38
|
+
|
|
39
|
+
**Scanning order:**
|
|
40
|
+
1. Route/controller files (endpoints, methods, URL patterns)
|
|
41
|
+
2. DTOs / models / types / interfaces (request/response schemas)
|
|
42
|
+
3. Middleware (auth schemes, rate limiting, CORS)
|
|
43
|
+
4. Validation logic (required fields, constraints, formats)
|
|
44
|
+
5. Error handling (error response shapes, status codes)
|
|
45
|
+
|
|
46
|
+
### Source B — Spec / Requirements Document
|
|
47
|
+
|
|
48
|
+
If a design document, requirements doc, or API description is provided:
|
|
49
|
+
1. Extract each endpoint (method + path)
|
|
50
|
+
2. Identify request parameters, bodies, and response shapes from descriptions
|
|
51
|
+
3. Infer validation rules and constraints from requirements language
|
|
52
|
+
4. Map described auth mechanisms to OpenAPI securitySchemes
|
|
53
|
+
|
|
54
|
+
### Mixed Source
|
|
55
|
+
|
|
56
|
+
When both are available, **codebase is truth, spec fills gaps**. Flag discrepancies between the two.
|
|
57
|
+
|
|
58
|
+
## Generation Process
|
|
59
|
+
|
|
60
|
+
### Step 1 — Discover Endpoints
|
|
61
|
+
|
|
62
|
+
For each endpoint, capture:
|
|
63
|
+
- HTTP method
|
|
64
|
+
- URL path (with path parameters identified)
|
|
65
|
+
- Handler function / controller method name
|
|
66
|
+
- Associated middleware (auth, validation)
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
GET /api/users → listUsers
|
|
70
|
+
POST /api/users → createUser
|
|
71
|
+
GET /api/users/:id → getUser
|
|
72
|
+
PUT /api/users/:id → updateUser
|
|
73
|
+
DELETE /api/users/:id → deleteUser
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Step 2 — Extract Schemas
|
|
77
|
+
|
|
78
|
+
For each endpoint, extract:
|
|
79
|
+
- **Path parameters** — name, type, required (always true for path params)
|
|
80
|
+
- **Query parameters** — name, type, required/optional, defaults, enums
|
|
81
|
+
- **Request body** — content type, schema (from DTO/model/interface)
|
|
82
|
+
- **Response body** — per status code, content type, schema
|
|
83
|
+
- **Headers** — custom required headers
|
|
84
|
+
|
|
85
|
+
Map language types to OpenAPI types:
|
|
86
|
+
|
|
87
|
+
| Source Type | OpenAPI Type | Format |
|
|
88
|
+
|-------------|-------------|--------|
|
|
89
|
+
| `string` | `string` | — |
|
|
90
|
+
| `number`, `float`, `double` | `number` | `float` / `double` |
|
|
91
|
+
| `int`, `integer` | `integer` | `int32` / `int64` |
|
|
92
|
+
| `boolean`, `bool` | `boolean` | — |
|
|
93
|
+
| `Date`, `datetime` | `string` | `date-time` |
|
|
94
|
+
| `UUID`, `uuid` | `string` | `uuid` |
|
|
95
|
+
| `email` (validated) | `string` | `email` |
|
|
96
|
+
| Array of T | `array` | items: T |
|
|
97
|
+
| Object / interface | `object` | properties from fields |
|
|
98
|
+
|
|
99
|
+
### Step 3 — Build OpenAPI Structure
|
|
100
|
+
|
|
101
|
+
Assemble the spec following this skeleton:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
openapi: 3.0.3
|
|
105
|
+
info:
|
|
106
|
+
title: <Project Name> API
|
|
107
|
+
description: <from README or package description>
|
|
108
|
+
version: <from package version or "1.0.0">
|
|
109
|
+
contact:
|
|
110
|
+
name: <from package author>
|
|
111
|
+
|
|
112
|
+
servers:
|
|
113
|
+
- url: http://localhost:<port>
|
|
114
|
+
description: Local development
|
|
115
|
+
- url: https://api.<domain>
|
|
116
|
+
description: Production
|
|
117
|
+
|
|
118
|
+
paths:
|
|
119
|
+
/api/resource:
|
|
120
|
+
get:
|
|
121
|
+
tags: [Resource]
|
|
122
|
+
summary: List resources
|
|
123
|
+
operationId: listResources
|
|
124
|
+
parameters: [...]
|
|
125
|
+
responses:
|
|
126
|
+
'200': { description: Success, content: ... }
|
|
127
|
+
'401': { $ref: '#/components/responses/Unauthorized' }
|
|
128
|
+
'500': { $ref: '#/components/responses/InternalError' }
|
|
129
|
+
|
|
130
|
+
components:
|
|
131
|
+
schemas: { ... }
|
|
132
|
+
responses:
|
|
133
|
+
BadRequest: { ... }
|
|
134
|
+
Unauthorized: { ... }
|
|
135
|
+
Forbidden: { ... }
|
|
136
|
+
NotFound: { ... }
|
|
137
|
+
InternalError: { ... }
|
|
138
|
+
securitySchemes: { ... }
|
|
139
|
+
|
|
140
|
+
security:
|
|
141
|
+
- bearerAuth: []
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Step 4 — Include All Details
|
|
145
|
+
|
|
146
|
+
**For EVERY endpoint, include these response codes at minimum:**
|
|
147
|
+
|
|
148
|
+
| Method | Success | Common Errors |
|
|
149
|
+
|--------|---------|---------------|
|
|
150
|
+
| GET (list) | 200 | 400, 401, 403, 500 |
|
|
151
|
+
| GET (single) | 200 | 400, 401, 403, 404, 500 |
|
|
152
|
+
| POST (create) | 201 | 400, 401, 403, 409, 422, 500 |
|
|
153
|
+
| PUT/PATCH | 200 | 400, 401, 403, 404, 422, 500 |
|
|
154
|
+
| DELETE | 200 or 204 | 400, 401, 403, 404, 500 |
|
|
155
|
+
|
|
156
|
+
**For request bodies:**
|
|
157
|
+
- Mark required fields explicitly
|
|
158
|
+
- Include `example` values with realistic data
|
|
159
|
+
- Add `minLength`, `maxLength`, `minimum`, `maximum`, `pattern` where validation exists
|
|
160
|
+
|
|
161
|
+
**For parameters:**
|
|
162
|
+
- Include `description` for every parameter
|
|
163
|
+
- Mark `required: true/false` explicitly
|
|
164
|
+
- Add `enum` values where applicable
|
|
165
|
+
|
|
166
|
+
### Step 5 — Write File
|
|
167
|
+
|
|
168
|
+
Output the complete spec as:
|
|
169
|
+
- **Default:** `openapi.yaml` at the project root
|
|
170
|
+
- **User override:** write to the path specified by the developer
|
|
171
|
+
- **Format:** YAML preferred (more readable), JSON if requested
|
|
172
|
+
|
|
173
|
+
### Step 6 — Verify
|
|
174
|
+
|
|
175
|
+
Before claiming the spec is complete:
|
|
176
|
+
|
|
177
|
+
1. **Structural check** — every path has at least one operation, every operation has at least one response
|
|
178
|
+
2. **Schema completeness** — all `$ref` references resolve to defined components
|
|
179
|
+
3. **Consistency** — operationIds are unique, tag names are consistent, naming follows convention (camelCase for operationId, PascalCase for schemas)
|
|
180
|
+
4. **Error responses** — every mutating endpoint has 400/401/500 responses
|
|
181
|
+
5. **Examples** — every schema has an `example` or individual field examples
|
|
182
|
+
6. Apply `digiqagent:verification-before-completion` — evidence before claims
|
|
183
|
+
|
|
184
|
+
## Red Flags — STOP and Fix
|
|
185
|
+
|
|
186
|
+
| Problem | Fix |
|
|
187
|
+
|---------|-----|
|
|
188
|
+
| Endpoint in code but not in spec | Add it. No undocumented endpoints. |
|
|
189
|
+
| Response code missing | Add all relevant codes per the table above. |
|
|
190
|
+
| Schema has no `example` | Add realistic example data. |
|
|
191
|
+
| `$ref` points to undefined schema | Define the schema or fix the reference. |
|
|
192
|
+
| No `securitySchemes` but auth middleware exists | Define the scheme (bearer, apiKey, oauth2). |
|
|
193
|
+
| Path parameter not in `parameters` | Add it with `in: path, required: true`. |
|
|
194
|
+
| `operationId` missing or duplicated | Every operation needs a unique operationId. |
|
|
195
|
+
| Inconsistent naming | Pick a convention and apply it everywhere. |
|
|
196
|
+
| No error response schemas | Define standard error response in components. |
|
|
197
|
+
|
|
198
|
+
## Common Patterns
|
|
199
|
+
|
|
200
|
+
See @openapi-patterns.md for reusable patterns:
|
|
201
|
+
- Standard error response schema
|
|
202
|
+
- Pagination (offset/limit and cursor-based)
|
|
203
|
+
- Authentication schemes
|
|
204
|
+
- File upload/download
|
|
205
|
+
- Common headers
|
|
206
|
+
|
|
207
|
+
## Naming Conventions
|
|
208
|
+
|
|
209
|
+
| Element | Convention | Example |
|
|
210
|
+
|---------|-----------|---------|
|
|
211
|
+
| operationId | camelCase, verb + noun | `listUsers`, `createOrder` |
|
|
212
|
+
| Schema name | PascalCase | `User`, `CreateUserRequest` |
|
|
213
|
+
| Path | kebab-case, plural nouns | `/api/user-profiles` |
|
|
214
|
+
| Tags | PascalCase, plural | `Users`, `OrderItems` |
|
|
215
|
+
| Query params | camelCase | `pageSize`, `sortBy` |
|
|
216
|
+
|
|
217
|
+
## Verification Checklist
|
|
218
|
+
|
|
219
|
+
Before marking generation complete:
|
|
220
|
+
|
|
221
|
+
- [ ] Every route/controller endpoint has a corresponding path in the spec
|
|
222
|
+
- [ ] Every path operation has an operationId
|
|
223
|
+
- [ ] Every path operation has at least success + error responses
|
|
224
|
+
- [ ] Every request body schema marks required fields
|
|
225
|
+
- [ ] Every schema includes example values
|
|
226
|
+
- [ ] All `$ref` references resolve
|
|
227
|
+
- [ ] Security schemes match actual auth implementation
|
|
228
|
+
- [ ] Servers list includes at least local dev URL
|
|
229
|
+
- [ ] Info section has title, description, version
|
|
230
|
+
- [ ] File written and path confirmed to user
|
|
231
|
+
|
|
232
|
+
Can't check all boxes? Fix the spec. Don't ship incomplete documentation.
|
|
233
|
+
|
|
234
|
+
## Next Steps
|
|
235
|
+
|
|
236
|
+
After generating the OpenAPI spec:
|
|
237
|
+
1. Use `digiqagent:postman-collection-generator` to produce a Postman collection from the spec
|
|
238
|
+
2. Use `digiqagent:postman-test-suite-generator` to add positive/negative test scenarios
|