@sylix/coworker 2.0.11 → 2.0.14

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 (169) hide show
  1. package/dist/commands/slash/config.d.ts.map +1 -1
  2. package/dist/commands/slash/config.js +22 -4
  3. package/dist/commands/slash/config.js.map +1 -1
  4. package/dist/core/CoWorkerAgent.d.ts.map +1 -1
  5. package/dist/core/CoWorkerAgent.js +6 -3
  6. package/dist/core/CoWorkerAgent.js.map +1 -1
  7. package/dist/skills/defaults/accessibility/screen-reader-testing.md +545 -0
  8. package/dist/skills/defaults/accessibility/wcag-audit-patterns.md +555 -0
  9. package/dist/skills/defaults/ai-ml/rag.md +276 -0
  10. package/dist/skills/defaults/backend-development/api-design-principles.md +528 -0
  11. package/dist/skills/defaults/backend-development/api-design.md +285 -0
  12. package/dist/skills/defaults/backend-development/architecture-patterns.md +494 -0
  13. package/dist/skills/defaults/backend-development/async-python.md +237 -0
  14. package/dist/skills/defaults/backend-development/auth-implementation-patterns.md +638 -0
  15. package/dist/skills/defaults/backend-development/bazel-build-optimization.md +387 -0
  16. package/dist/skills/defaults/backend-development/billing-automation/SKILL.md +566 -0
  17. package/dist/skills/defaults/backend-development/code-review-excellence.md +538 -0
  18. package/dist/skills/defaults/backend-development/cqrs-implementation.md +554 -0
  19. package/dist/skills/defaults/backend-development/database-design.md +305 -0
  20. package/dist/skills/defaults/backend-development/debugging-strategies.md +536 -0
  21. package/dist/skills/defaults/backend-development/e2e-testing-patterns.md +544 -0
  22. package/dist/skills/defaults/backend-development/error-handling-patterns.md +641 -0
  23. package/dist/skills/defaults/backend-development/fastapi-templates.md +559 -0
  24. package/dist/skills/defaults/backend-development/fastapi.md +309 -0
  25. package/dist/skills/defaults/backend-development/git-advanced-workflows.md +405 -0
  26. package/dist/skills/defaults/backend-development/microservices-patterns.md +595 -0
  27. package/dist/skills/defaults/backend-development/microservices.md +284 -0
  28. package/dist/skills/defaults/backend-development/monorepo-management.md +623 -0
  29. package/dist/skills/defaults/backend-development/nodejs-backend-patterns.md +1048 -0
  30. package/dist/skills/defaults/backend-development/nx-workspace-patterns.md +457 -0
  31. package/dist/skills/defaults/backend-development/paypal-integration/SKILL.md +478 -0
  32. package/dist/skills/defaults/backend-development/pci-compliance/SKILL.md +480 -0
  33. package/dist/skills/defaults/backend-development/python-anti-patterns.md +349 -0
  34. package/dist/skills/defaults/backend-development/python-background-jobs.md +364 -0
  35. package/dist/skills/defaults/backend-development/python-code-style.md +360 -0
  36. package/dist/skills/defaults/backend-development/python-configuration.md +368 -0
  37. package/dist/skills/defaults/backend-development/python-design-patterns.md +296 -0
  38. package/dist/skills/defaults/backend-development/python-error-handling.md +323 -0
  39. package/dist/skills/defaults/backend-development/python-packaging.md +887 -0
  40. package/dist/skills/defaults/backend-development/python-performance-optimization.md +874 -0
  41. package/dist/skills/defaults/backend-development/python-project-structure.md +252 -0
  42. package/dist/skills/defaults/backend-development/python-resilience.md +376 -0
  43. package/dist/skills/defaults/backend-development/python-resource-management.md +421 -0
  44. package/dist/skills/defaults/backend-development/python-type-safety.md +428 -0
  45. package/dist/skills/defaults/backend-development/sql-optimization-patterns.md +509 -0
  46. package/dist/skills/defaults/backend-development/stripe-integration/SKILL.md +522 -0
  47. package/dist/skills/defaults/backend-development/turborepo-caching.md +376 -0
  48. package/dist/skills/defaults/blockchain/defi-protocol-templates.md +430 -0
  49. package/dist/skills/defaults/blockchain/nft-standards.md +364 -0
  50. package/dist/skills/defaults/blockchain/solidity-security.md +514 -0
  51. package/dist/skills/defaults/blockchain/web3-testing.md +360 -0
  52. package/dist/skills/defaults/business/competitive-landscape/SKILL.md +527 -0
  53. package/dist/skills/defaults/business/market-sizing-analysis/SKILL.md +451 -0
  54. package/dist/skills/defaults/business/startup-financial-modeling/SKILL.md +494 -0
  55. package/dist/skills/defaults/business/startup-metrics-framework/SKILL.md +564 -0
  56. package/dist/skills/defaults/business/team-composition-analysis.md +437 -0
  57. package/dist/skills/defaults/compliance/employment-contract-templates/SKILL.md +527 -0
  58. package/dist/skills/defaults/compliance/gdpr-data-handling/SKILL.md +630 -0
  59. package/dist/skills/defaults/data-engineering/airflow-dag-patterns.md +436 -0
  60. package/dist/skills/defaults/data-engineering/airflow.md +519 -0
  61. package/dist/skills/defaults/data-engineering/data-quality.md +583 -0
  62. package/dist/skills/defaults/data-engineering/dbt-transformation-patterns.md +482 -0
  63. package/dist/skills/defaults/data-engineering/dbt.md +556 -0
  64. package/dist/skills/defaults/data-engineering/ml-pipeline-workflow/SKILL.md +247 -0
  65. package/dist/skills/defaults/data-engineering/spark-optimization.md +348 -0
  66. package/dist/skills/defaults/data-engineering/spark.md +411 -0
  67. package/dist/skills/defaults/database/postgresql.md +202 -0
  68. package/dist/skills/defaults/debugging/systematic-debugging.md +249 -0
  69. package/dist/skills/defaults/devops/architecture-decision-records.md +448 -0
  70. package/dist/skills/defaults/devops/changelog-automation.md +580 -0
  71. package/dist/skills/defaults/devops/cicd.md +314 -0
  72. package/dist/skills/defaults/devops/cloud.md +263 -0
  73. package/dist/skills/defaults/devops/code-review-excellence.md +299 -0
  74. package/dist/skills/defaults/devops/cost-optimization.md +295 -0
  75. package/dist/skills/defaults/devops/deployment-pipeline-design.md +356 -0
  76. package/dist/skills/defaults/devops/docker.md +281 -0
  77. package/dist/skills/defaults/devops/git-workflows.md +205 -0
  78. package/dist/skills/defaults/devops/github-actions.md +311 -0
  79. package/dist/skills/defaults/devops/gitlab-ci-patterns.md +266 -0
  80. package/dist/skills/defaults/devops/hybrid-cloud-networking.md +241 -0
  81. package/dist/skills/defaults/devops/istio-traffic-management.md +327 -0
  82. package/dist/skills/defaults/devops/kubernetes.md +339 -0
  83. package/dist/skills/defaults/devops/linkerd-patterns.md +311 -0
  84. package/dist/skills/defaults/devops/multi-cloud-architecture.md +181 -0
  85. package/dist/skills/defaults/devops/observability.md +243 -0
  86. package/dist/skills/defaults/devops/openapi-spec-generation.md +1024 -0
  87. package/dist/skills/defaults/devops/postmortem-writing.md +396 -0
  88. package/dist/skills/defaults/devops/prometheus-configuration.md +265 -0
  89. package/dist/skills/defaults/devops/secrets-management.md +341 -0
  90. package/dist/skills/defaults/devops/service-mesh-observability.md +385 -0
  91. package/dist/skills/defaults/devops/terraform-module-library.md +244 -0
  92. package/dist/skills/defaults/finance/backtesting-frameworks/SKILL.md +663 -0
  93. package/dist/skills/defaults/finance/risk-metrics-calculation/SKILL.md +557 -0
  94. package/dist/skills/defaults/frontend/accessibility-compliance.md +420 -0
  95. package/dist/skills/defaults/frontend/design-system-patterns.md +337 -0
  96. package/dist/skills/defaults/frontend/interaction-design.md +327 -0
  97. package/dist/skills/defaults/frontend/javascript.md +311 -0
  98. package/dist/skills/defaults/frontend/modern-javascript-patterns.md +927 -0
  99. package/dist/skills/defaults/frontend/react-native-design.md +440 -0
  100. package/dist/skills/defaults/frontend/react.md +345 -0
  101. package/dist/skills/defaults/frontend/responsive-design.md +472 -0
  102. package/dist/skills/defaults/frontend/tailwind-design-system.md +337 -0
  103. package/dist/skills/defaults/frontend/typescript-advanced-types.md +724 -0
  104. package/dist/skills/defaults/frontend/typescript.md +334 -0
  105. package/dist/skills/defaults/frontend/visual-design-foundations.md +326 -0
  106. package/dist/skills/defaults/frontend/web-component-design.md +279 -0
  107. package/dist/skills/defaults/game-development/godot-gdscript-patterns.md +188 -0
  108. package/dist/skills/defaults/game-development/unity-ecs-patterns.md +594 -0
  109. package/dist/skills/defaults/kubernetes/gitops-workflow.md +285 -0
  110. package/dist/skills/defaults/kubernetes/gitops.md +280 -0
  111. package/dist/skills/defaults/kubernetes/helm-chart-scaffolding.md +553 -0
  112. package/dist/skills/defaults/kubernetes/helm.md +343 -0
  113. package/dist/skills/defaults/kubernetes/k8s-manifest-generator.md +501 -0
  114. package/dist/skills/defaults/kubernetes/k8s-security-policies.md +342 -0
  115. package/dist/skills/defaults/kubernetes/manifests.md +330 -0
  116. package/dist/skills/defaults/kubernetes/security.md +337 -0
  117. package/dist/skills/defaults/llm-application/embedding-strategies.md +608 -0
  118. package/dist/skills/defaults/llm-application/hybrid-search-implementation.md +570 -0
  119. package/dist/skills/defaults/llm-application/hybrid-search.md +570 -0
  120. package/dist/skills/defaults/llm-application/langchain-architecture.md +666 -0
  121. package/dist/skills/defaults/llm-application/langchain.md +259 -0
  122. package/dist/skills/defaults/llm-application/llm-evaluation.md +695 -0
  123. package/dist/skills/defaults/llm-application/prompt-engineering-patterns.md +449 -0
  124. package/dist/skills/defaults/llm-application/prompt-engineering.md +219 -0
  125. package/dist/skills/defaults/llm-application/rag-implementation.md +434 -0
  126. package/dist/skills/defaults/llm-application/similarity-search-patterns.md +560 -0
  127. package/dist/skills/defaults/llm-application/similarity-search.md +560 -0
  128. package/dist/skills/defaults/llm-application/vector-index-tuning.md +523 -0
  129. package/dist/skills/defaults/mobile/mobile-android-design.md +440 -0
  130. package/dist/skills/defaults/mobile/mobile-ios-design.md +266 -0
  131. package/dist/skills/defaults/monitoring/distributed-tracing.md +436 -0
  132. package/dist/skills/defaults/monitoring/grafana-dashboards.md +370 -0
  133. package/dist/skills/defaults/monitoring/prometheus-configuration.md +379 -0
  134. package/dist/skills/defaults/monitoring/slo-implementation.md +323 -0
  135. package/dist/skills/defaults/refactoring/code-refactoring.md +349 -0
  136. package/dist/skills/defaults/security/anti-reversing-techniques/SKILL.md +559 -0
  137. package/dist/skills/defaults/security/auditor.md +168 -0
  138. package/dist/skills/defaults/security/binary-analysis-patterns/SKILL.md +438 -0
  139. package/dist/skills/defaults/security/memory-forensics/SKILL.md +483 -0
  140. package/dist/skills/defaults/security/mtls-configuration.md +349 -0
  141. package/dist/skills/defaults/security/protocol-reverse-engineering/SKILL.md +520 -0
  142. package/dist/skills/defaults/security/sast-configuration.md +182 -0
  143. package/dist/skills/defaults/security/security.md +313 -0
  144. package/dist/skills/defaults/security/stride-analysis.md +273 -0
  145. package/dist/skills/defaults/security/threat-mitigation-mapping.md +290 -0
  146. package/dist/skills/defaults/systems/bash-defensive-patterns/SKILL.md +539 -0
  147. package/dist/skills/defaults/systems/bats-testing-patterns/SKILL.md +631 -0
  148. package/dist/skills/defaults/systems/go-concurrency-patterns.md +657 -0
  149. package/dist/skills/defaults/systems/memory-safety-patterns.md +605 -0
  150. package/dist/skills/defaults/systems/rust-async-patterns.md +519 -0
  151. package/dist/skills/defaults/systems/shellcheck-configuration/SKILL.md +456 -0
  152. package/dist/skills/defaults/team-collaboration/multi-reviewer-patterns.md +126 -0
  153. package/dist/skills/defaults/team-collaboration/parallel-feature-development.md +151 -0
  154. package/dist/skills/defaults/testing/javascript-testing-patterns.md +1021 -0
  155. package/dist/skills/defaults/testing/python-testing-patterns.md +351 -0
  156. package/dist/skills/defaults/testing/testing.md +332 -0
  157. package/dist/skills/defaults/workflows/context-driven-development.md +384 -0
  158. package/dist/skills/defaults/workflows/track-management.md +592 -0
  159. package/dist/skills/defaults/workflows/workflow-patterns.md +622 -0
  160. package/dist/skills/index.d.ts +11 -0
  161. package/dist/skills/index.d.ts.map +1 -0
  162. package/dist/skills/index.js +129 -0
  163. package/dist/skills/index.js.map +1 -0
  164. package/dist/utils/character.js +4 -4
  165. package/dist/utils/character.js.map +1 -1
  166. package/dist/utils/inputbar.d.ts.map +1 -1
  167. package/dist/utils/inputbar.js +7 -0
  168. package/dist/utils/inputbar.js.map +1 -1
  169. package/package.json +1 -1
@@ -0,0 +1,1024 @@
1
+ ---
2
+ name: openapi-spec-generation
3
+ description: Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.
4
+ ---
5
+
6
+ # OpenAPI Spec Generation
7
+
8
+ Comprehensive patterns for creating, maintaining, and validating OpenAPI 3.1 specifications for RESTful APIs.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - Creating API documentation from scratch
13
+ - Generating OpenAPI specs from existing code
14
+ - Designing API contracts (design-first approach)
15
+ - Validating API implementations against specs
16
+ - Generating client SDKs from specs
17
+ - Setting up API documentation portals
18
+
19
+ ## Core Concepts
20
+
21
+ ### 1. OpenAPI 3.1 Structure
22
+
23
+ ```yaml
24
+ openapi: 3.1.0
25
+ info:
26
+ title: API Title
27
+ version: 1.0.0
28
+ servers:
29
+ - url: https://api.example.com/v1
30
+ paths:
31
+ /resources:
32
+ get: ...
33
+ components:
34
+ schemas: ...
35
+ securitySchemes: ...
36
+ ```
37
+
38
+ ### 2. Design Approaches
39
+
40
+ | Approach | Description | Best For |
41
+ | ---------------- | ---------------------------- | ------------------- |
42
+ | **Design-First** | Write spec before code | New APIs, contracts |
43
+ | **Code-First** | Generate spec from code | Existing APIs |
44
+ | **Hybrid** | Annotate code, generate spec | Evolving APIs |
45
+
46
+ ## Templates
47
+
48
+ ### Template 1: Complete API Specification
49
+
50
+ ```yaml
51
+ openapi: 3.1.0
52
+ info:
53
+ title: User Management API
54
+ description: |
55
+ API for managing users and their profiles.
56
+
57
+ ## Authentication
58
+ All endpoints require Bearer token authentication.
59
+
60
+ ## Rate Limiting
61
+ - 1000 requests per minute for standard tier
62
+ - 10000 requests per minute for enterprise tier
63
+ version: 2.0.0
64
+ contact:
65
+ name: API Support
66
+ email: api-support@example.com
67
+ url: https://docs.example.com
68
+ license:
69
+ name: MIT
70
+ url: https://opensource.org/licenses/MIT
71
+
72
+ servers:
73
+ - url: https://api.example.com/v2
74
+ description: Production
75
+ - url: https://staging-api.example.com/v2
76
+ description: Staging
77
+ - url: http://localhost:3000/v2
78
+ description: Local development
79
+
80
+ tags:
81
+ - name: Users
82
+ description: User management operations
83
+ - name: Profiles
84
+ description: User profile operations
85
+ - name: Admin
86
+ description: Administrative operations
87
+
88
+ paths:
89
+ /users:
90
+ get:
91
+ operationId: listUsers
92
+ summary: List all users
93
+ description: Returns a paginated list of users with optional filtering.
94
+ tags:
95
+ - Users
96
+ parameters:
97
+ - $ref: "#/components/parameters/PageParam"
98
+ - $ref: "#/components/parameters/LimitParam"
99
+ - name: status
100
+ in: query
101
+ description: Filter by user status
102
+ schema:
103
+ $ref: "#/components/schemas/UserStatus"
104
+ - name: search
105
+ in: query
106
+ description: Search by name or email
107
+ schema:
108
+ type: string
109
+ minLength: 2
110
+ maxLength: 100
111
+ responses:
112
+ "200":
113
+ description: Successful response
114
+ content:
115
+ application/json:
116
+ schema:
117
+ $ref: "#/components/schemas/UserListResponse"
118
+ examples:
119
+ default:
120
+ $ref: "#/components/examples/UserListExample"
121
+ "400":
122
+ $ref: "#/components/responses/BadRequest"
123
+ "401":
124
+ $ref: "#/components/responses/Unauthorized"
125
+ "429":
126
+ $ref: "#/components/responses/RateLimited"
127
+ security:
128
+ - bearerAuth: []
129
+
130
+ post:
131
+ operationId: createUser
132
+ summary: Create a new user
133
+ description: Creates a new user account and sends welcome email.
134
+ tags:
135
+ - Users
136
+ requestBody:
137
+ required: true
138
+ content:
139
+ application/json:
140
+ schema:
141
+ $ref: "#/components/schemas/CreateUserRequest"
142
+ examples:
143
+ standard:
144
+ summary: Standard user
145
+ value:
146
+ email: user@example.com
147
+ name: John Doe
148
+ role: user
149
+ admin:
150
+ summary: Admin user
151
+ value:
152
+ email: admin@example.com
153
+ name: Admin User
154
+ role: admin
155
+ responses:
156
+ "201":
157
+ description: User created successfully
158
+ content:
159
+ application/json:
160
+ schema:
161
+ $ref: "#/components/schemas/User"
162
+ headers:
163
+ Location:
164
+ description: URL of created user
165
+ schema:
166
+ type: string
167
+ format: uri
168
+ "400":
169
+ $ref: "#/components/responses/BadRequest"
170
+ "409":
171
+ description: Email already exists
172
+ content:
173
+ application/json:
174
+ schema:
175
+ $ref: "#/components/schemas/Error"
176
+ security:
177
+ - bearerAuth: []
178
+
179
+ /users/{userId}:
180
+ parameters:
181
+ - $ref: "#/components/parameters/UserIdParam"
182
+
183
+ get:
184
+ operationId: getUser
185
+ summary: Get user by ID
186
+ tags:
187
+ - Users
188
+ responses:
189
+ "200":
190
+ description: Successful response
191
+ content:
192
+ application/json:
193
+ schema:
194
+ $ref: "#/components/schemas/User"
195
+ "404":
196
+ $ref: "#/components/responses/NotFound"
197
+ security:
198
+ - bearerAuth: []
199
+
200
+ patch:
201
+ operationId: updateUser
202
+ summary: Update user
203
+ tags:
204
+ - Users
205
+ requestBody:
206
+ required: true
207
+ content:
208
+ application/json:
209
+ schema:
210
+ $ref: "#/components/schemas/UpdateUserRequest"
211
+ responses:
212
+ "200":
213
+ description: User updated
214
+ content:
215
+ application/json:
216
+ schema:
217
+ $ref: "#/components/schemas/User"
218
+ "400":
219
+ $ref: "#/components/responses/BadRequest"
220
+ "404":
221
+ $ref: "#/components/responses/NotFound"
222
+ security:
223
+ - bearerAuth: []
224
+
225
+ delete:
226
+ operationId: deleteUser
227
+ summary: Delete user
228
+ tags:
229
+ - Users
230
+ - Admin
231
+ responses:
232
+ "204":
233
+ description: User deleted
234
+ "404":
235
+ $ref: "#/components/responses/NotFound"
236
+ security:
237
+ - bearerAuth: []
238
+ - apiKey: []
239
+
240
+ components:
241
+ schemas:
242
+ User:
243
+ type: object
244
+ required:
245
+ - id
246
+ - email
247
+ - name
248
+ - status
249
+ - createdAt
250
+ properties:
251
+ id:
252
+ type: string
253
+ format: uuid
254
+ readOnly: true
255
+ description: Unique user identifier
256
+ email:
257
+ type: string
258
+ format: email
259
+ description: User email address
260
+ name:
261
+ type: string
262
+ minLength: 1
263
+ maxLength: 100
264
+ description: User display name
265
+ status:
266
+ $ref: "#/components/schemas/UserStatus"
267
+ role:
268
+ type: string
269
+ enum: [user, moderator, admin]
270
+ default: user
271
+ avatar:
272
+ type: string
273
+ format: uri
274
+ nullable: true
275
+ metadata:
276
+ type: object
277
+ additionalProperties: true
278
+ description: Custom metadata
279
+ createdAt:
280
+ type: string
281
+ format: date-time
282
+ readOnly: true
283
+ updatedAt:
284
+ type: string
285
+ format: date-time
286
+ readOnly: true
287
+
288
+ UserStatus:
289
+ type: string
290
+ enum: [active, inactive, suspended, pending]
291
+ description: User account status
292
+
293
+ CreateUserRequest:
294
+ type: object
295
+ required:
296
+ - email
297
+ - name
298
+ properties:
299
+ email:
300
+ type: string
301
+ format: email
302
+ name:
303
+ type: string
304
+ minLength: 1
305
+ maxLength: 100
306
+ role:
307
+ type: string
308
+ enum: [user, moderator, admin]
309
+ default: user
310
+ metadata:
311
+ type: object
312
+ additionalProperties: true
313
+
314
+ UpdateUserRequest:
315
+ type: object
316
+ minProperties: 1
317
+ properties:
318
+ name:
319
+ type: string
320
+ minLength: 1
321
+ maxLength: 100
322
+ status:
323
+ $ref: "#/components/schemas/UserStatus"
324
+ role:
325
+ type: string
326
+ enum: [user, moderator, admin]
327
+ metadata:
328
+ type: object
329
+ additionalProperties: true
330
+
331
+ UserListResponse:
332
+ type: object
333
+ required:
334
+ - data
335
+ - pagination
336
+ properties:
337
+ data:
338
+ type: array
339
+ items:
340
+ $ref: "#/components/schemas/User"
341
+ pagination:
342
+ $ref: "#/components/schemas/Pagination"
343
+
344
+ Pagination:
345
+ type: object
346
+ required:
347
+ - page
348
+ - limit
349
+ - total
350
+ - totalPages
351
+ properties:
352
+ page:
353
+ type: integer
354
+ minimum: 1
355
+ limit:
356
+ type: integer
357
+ minimum: 1
358
+ maximum: 100
359
+ total:
360
+ type: integer
361
+ minimum: 0
362
+ totalPages:
363
+ type: integer
364
+ minimum: 0
365
+ hasNext:
366
+ type: boolean
367
+ hasPrev:
368
+ type: boolean
369
+
370
+ Error:
371
+ type: object
372
+ required:
373
+ - code
374
+ - message
375
+ properties:
376
+ code:
377
+ type: string
378
+ description: Error code for programmatic handling
379
+ message:
380
+ type: string
381
+ description: Human-readable error message
382
+ details:
383
+ type: array
384
+ items:
385
+ type: object
386
+ properties:
387
+ field:
388
+ type: string
389
+ message:
390
+ type: string
391
+ requestId:
392
+ type: string
393
+ description: Request ID for support
394
+
395
+ parameters:
396
+ UserIdParam:
397
+ name: userId
398
+ in: path
399
+ required: true
400
+ description: User ID
401
+ schema:
402
+ type: string
403
+ format: uuid
404
+
405
+ PageParam:
406
+ name: page
407
+ in: query
408
+ description: Page number (1-based)
409
+ schema:
410
+ type: integer
411
+ minimum: 1
412
+ default: 1
413
+
414
+ LimitParam:
415
+ name: limit
416
+ in: query
417
+ description: Items per page
418
+ schema:
419
+ type: integer
420
+ minimum: 1
421
+ maximum: 100
422
+ default: 20
423
+
424
+ responses:
425
+ BadRequest:
426
+ description: Invalid request
427
+ content:
428
+ application/json:
429
+ schema:
430
+ $ref: "#/components/schemas/Error"
431
+ example:
432
+ code: VALIDATION_ERROR
433
+ message: Invalid request parameters
434
+ details:
435
+ - field: email
436
+ message: Must be a valid email address
437
+
438
+ Unauthorized:
439
+ description: Authentication required
440
+ content:
441
+ application/json:
442
+ schema:
443
+ $ref: "#/components/schemas/Error"
444
+ example:
445
+ code: UNAUTHORIZED
446
+ message: Authentication required
447
+
448
+ NotFound:
449
+ description: Resource not found
450
+ content:
451
+ application/json:
452
+ schema:
453
+ $ref: "#/components/schemas/Error"
454
+ example:
455
+ code: NOT_FOUND
456
+ message: User not found
457
+
458
+ RateLimited:
459
+ description: Too many requests
460
+ content:
461
+ application/json:
462
+ schema:
463
+ $ref: "#/components/schemas/Error"
464
+ headers:
465
+ Retry-After:
466
+ description: Seconds until rate limit resets
467
+ schema:
468
+ type: integer
469
+ X-RateLimit-Limit:
470
+ description: Request limit per window
471
+ schema:
472
+ type: integer
473
+ X-RateLimit-Remaining:
474
+ description: Remaining requests in window
475
+ schema:
476
+ type: integer
477
+
478
+ examples:
479
+ UserListExample:
480
+ value:
481
+ data:
482
+ - id: "550e8400-e29b-41d4-a716-446655440000"
483
+ email: "john@example.com"
484
+ name: "John Doe"
485
+ status: "active"
486
+ role: "user"
487
+ createdAt: "2024-01-15T10:30:00Z"
488
+ pagination:
489
+ page: 1
490
+ limit: 20
491
+ total: 1
492
+ totalPages: 1
493
+ hasNext: false
494
+ hasPrev: false
495
+
496
+ securitySchemes:
497
+ bearerAuth:
498
+ type: http
499
+ scheme: bearer
500
+ bearerFormat: JWT
501
+ description: JWT token from /auth/login
502
+
503
+ apiKey:
504
+ type: apiKey
505
+ in: header
506
+ name: X-API-Key
507
+ description: API key for service-to-service calls
508
+
509
+ security:
510
+ - bearerAuth: []
511
+ ```
512
+
513
+ ### Template 2: Code-First Generation (Python/FastAPI)
514
+
515
+ ```python
516
+ # FastAPI with automatic OpenAPI generation
517
+ from fastapi import FastAPI, HTTPException, Query, Path, Depends
518
+ from pydantic import BaseModel, Field, EmailStr
519
+ from typing import Optional, List
520
+ from datetime import datetime
521
+ from uuid import UUID
522
+ from enum import Enum
523
+
524
+ app = FastAPI(
525
+ title="User Management API",
526
+ description="API for managing users and profiles",
527
+ version="2.0.0",
528
+ openapi_tags=[
529
+ {"name": "Users", "description": "User operations"},
530
+ {"name": "Profiles", "description": "Profile operations"},
531
+ ],
532
+ servers=[
533
+ {"url": "https://api.example.com/v2", "description": "Production"},
534
+ {"url": "http://localhost:8000", "description": "Development"},
535
+ ],
536
+ )
537
+
538
+ # Enums
539
+ class UserStatus(str, Enum):
540
+ active = "active"
541
+ inactive = "inactive"
542
+ suspended = "suspended"
543
+ pending = "pending"
544
+
545
+ class UserRole(str, Enum):
546
+ user = "user"
547
+ moderator = "moderator"
548
+ admin = "admin"
549
+
550
+ # Models
551
+ class UserBase(BaseModel):
552
+ email: EmailStr = Field(..., description="User email address")
553
+ name: str = Field(..., min_length=1, max_length=100, description="Display name")
554
+
555
+ class UserCreate(UserBase):
556
+ role: UserRole = Field(default=UserRole.user)
557
+ metadata: Optional[dict] = Field(default=None, description="Custom metadata")
558
+
559
+ model_config = {
560
+ "json_schema_extra": {
561
+ "examples": [
562
+ {
563
+ "email": "user@example.com",
564
+ "name": "John Doe",
565
+ "role": "user"
566
+ }
567
+ ]
568
+ }
569
+ }
570
+
571
+ class UserUpdate(BaseModel):
572
+ name: Optional[str] = Field(None, min_length=1, max_length=100)
573
+ status: Optional[UserStatus] = None
574
+ role: Optional[UserRole] = None
575
+ metadata: Optional[dict] = None
576
+
577
+ class User(UserBase):
578
+ id: UUID = Field(..., description="Unique identifier")
579
+ status: UserStatus
580
+ role: UserRole
581
+ avatar: Optional[str] = Field(None, description="Avatar URL")
582
+ metadata: Optional[dict] = None
583
+ created_at: datetime = Field(..., alias="createdAt")
584
+ updated_at: Optional[datetime] = Field(None, alias="updatedAt")
585
+
586
+ model_config = {"populate_by_name": True}
587
+
588
+ class Pagination(BaseModel):
589
+ page: int = Field(..., ge=1)
590
+ limit: int = Field(..., ge=1, le=100)
591
+ total: int = Field(..., ge=0)
592
+ total_pages: int = Field(..., ge=0, alias="totalPages")
593
+ has_next: bool = Field(..., alias="hasNext")
594
+ has_prev: bool = Field(..., alias="hasPrev")
595
+
596
+ class UserListResponse(BaseModel):
597
+ data: List[User]
598
+ pagination: Pagination
599
+
600
+ class ErrorDetail(BaseModel):
601
+ field: str
602
+ message: str
603
+
604
+ class ErrorResponse(BaseModel):
605
+ code: str = Field(..., description="Error code")
606
+ message: str = Field(..., description="Error message")
607
+ details: Optional[List[ErrorDetail]] = None
608
+ request_id: Optional[str] = Field(None, alias="requestId")
609
+
610
+ # Endpoints
611
+ @app.get(
612
+ "/users",
613
+ response_model=UserListResponse,
614
+ tags=["Users"],
615
+ summary="List all users",
616
+ description="Returns a paginated list of users with optional filtering.",
617
+ responses={
618
+ 400: {"model": ErrorResponse, "description": "Invalid request"},
619
+ 401: {"model": ErrorResponse, "description": "Unauthorized"},
620
+ },
621
+ )
622
+ async def list_users(
623
+ page: int = Query(1, ge=1, description="Page number"),
624
+ limit: int = Query(20, ge=1, le=100, description="Items per page"),
625
+ status: Optional[UserStatus] = Query(None, description="Filter by status"),
626
+ search: Optional[str] = Query(None, min_length=2, max_length=100),
627
+ ):
628
+ """
629
+ List users with pagination and filtering.
630
+
631
+ - **page**: Page number (1-based)
632
+ - **limit**: Number of items per page (max 100)
633
+ - **status**: Filter by user status
634
+ - **search**: Search by name or email
635
+ """
636
+ # Implementation
637
+ pass
638
+
639
+ @app.post(
640
+ "/users",
641
+ response_model=User,
642
+ status_code=201,
643
+ tags=["Users"],
644
+ summary="Create a new user",
645
+ responses={
646
+ 400: {"model": ErrorResponse},
647
+ 409: {"model": ErrorResponse, "description": "Email already exists"},
648
+ },
649
+ )
650
+ async def create_user(user: UserCreate):
651
+ """Create a new user and send welcome email."""
652
+ pass
653
+
654
+ @app.get(
655
+ "/users/{user_id}",
656
+ response_model=User,
657
+ tags=["Users"],
658
+ summary="Get user by ID",
659
+ responses={404: {"model": ErrorResponse}},
660
+ )
661
+ async def get_user(
662
+ user_id: UUID = Path(..., description="User ID"),
663
+ ):
664
+ """Retrieve a specific user by their ID."""
665
+ pass
666
+
667
+ @app.patch(
668
+ "/users/{user_id}",
669
+ response_model=User,
670
+ tags=["Users"],
671
+ summary="Update user",
672
+ responses={
673
+ 400: {"model": ErrorResponse},
674
+ 404: {"model": ErrorResponse},
675
+ },
676
+ )
677
+ async def update_user(
678
+ user_id: UUID = Path(..., description="User ID"),
679
+ user: UserUpdate = ...,
680
+ ):
681
+ """Update user attributes."""
682
+ pass
683
+
684
+ @app.delete(
685
+ "/users/{user_id}",
686
+ status_code=204,
687
+ tags=["Users", "Admin"],
688
+ summary="Delete user",
689
+ responses={404: {"model": ErrorResponse}},
690
+ )
691
+ async def delete_user(
692
+ user_id: UUID = Path(..., description="User ID"),
693
+ ):
694
+ """Permanently delete a user."""
695
+ pass
696
+
697
+ # Export OpenAPI spec
698
+ if __name__ == "__main__":
699
+ import json
700
+ print(json.dumps(app.openapi(), indent=2))
701
+ ```
702
+
703
+ ### Template 3: Code-First (TypeScript/Express with tsoa)
704
+
705
+ ```typescript
706
+ // tsoa generates OpenAPI from TypeScript decorators
707
+
708
+ import {
709
+ Controller,
710
+ Get,
711
+ Post,
712
+ Patch,
713
+ Delete,
714
+ Route,
715
+ Path,
716
+ Query,
717
+ Body,
718
+ Response,
719
+ SuccessResponse,
720
+ Tags,
721
+ Security,
722
+ Example,
723
+ } from "tsoa";
724
+
725
+ // Models
726
+ interface User {
727
+ /** Unique identifier */
728
+ id: string;
729
+ /** User email address */
730
+ email: string;
731
+ /** Display name */
732
+ name: string;
733
+ status: UserStatus;
734
+ role: UserRole;
735
+ /** Avatar URL */
736
+ avatar?: string;
737
+ /** Custom metadata */
738
+ metadata?: Record<string, unknown>;
739
+ createdAt: Date;
740
+ updatedAt?: Date;
741
+ }
742
+
743
+ enum UserStatus {
744
+ Active = "active",
745
+ Inactive = "inactive",
746
+ Suspended = "suspended",
747
+ Pending = "pending",
748
+ }
749
+
750
+ enum UserRole {
751
+ User = "user",
752
+ Moderator = "moderator",
753
+ Admin = "admin",
754
+ }
755
+
756
+ interface CreateUserRequest {
757
+ email: string;
758
+ name: string;
759
+ role?: UserRole;
760
+ metadata?: Record<string, unknown>;
761
+ }
762
+
763
+ interface UpdateUserRequest {
764
+ name?: string;
765
+ status?: UserStatus;
766
+ role?: UserRole;
767
+ metadata?: Record<string, unknown>;
768
+ }
769
+
770
+ interface Pagination {
771
+ page: number;
772
+ limit: number;
773
+ total: number;
774
+ totalPages: number;
775
+ hasNext: boolean;
776
+ hasPrev: boolean;
777
+ }
778
+
779
+ interface UserListResponse {
780
+ data: User[];
781
+ pagination: Pagination;
782
+ }
783
+
784
+ interface ErrorResponse {
785
+ code: string;
786
+ message: string;
787
+ details?: { field: string; message: string }[];
788
+ requestId?: string;
789
+ }
790
+
791
+ @Route("users")
792
+ @Tags("Users")
793
+ export class UsersController extends Controller {
794
+ /**
795
+ * List all users with pagination and filtering
796
+ * @param page Page number (1-based)
797
+ * @param limit Items per page (max 100)
798
+ * @param status Filter by user status
799
+ * @param search Search by name or email
800
+ */
801
+ @Get()
802
+ @Security("bearerAuth")
803
+ @Response<ErrorResponse>(400, "Invalid request")
804
+ @Response<ErrorResponse>(401, "Unauthorized")
805
+ @Example<UserListResponse>({
806
+ data: [
807
+ {
808
+ id: "550e8400-e29b-41d4-a716-446655440000",
809
+ email: "john@example.com",
810
+ name: "John Doe",
811
+ status: UserStatus.Active,
812
+ role: UserRole.User,
813
+ createdAt: new Date("2024-01-15T10:30:00Z"),
814
+ },
815
+ ],
816
+ pagination: {
817
+ page: 1,
818
+ limit: 20,
819
+ total: 1,
820
+ totalPages: 1,
821
+ hasNext: false,
822
+ hasPrev: false,
823
+ },
824
+ })
825
+ public async listUsers(
826
+ @Query() page: number = 1,
827
+ @Query() limit: number = 20,
828
+ @Query() status?: UserStatus,
829
+ @Query() search?: string,
830
+ ): Promise<UserListResponse> {
831
+ // Implementation
832
+ throw new Error("Not implemented");
833
+ }
834
+
835
+ /**
836
+ * Create a new user
837
+ */
838
+ @Post()
839
+ @Security("bearerAuth")
840
+ @SuccessResponse(201, "Created")
841
+ @Response<ErrorResponse>(400, "Invalid request")
842
+ @Response<ErrorResponse>(409, "Email already exists")
843
+ public async createUser(@Body() body: CreateUserRequest): Promise<User> {
844
+ this.setStatus(201);
845
+ throw new Error("Not implemented");
846
+ }
847
+
848
+ /**
849
+ * Get user by ID
850
+ * @param userId User ID
851
+ */
852
+ @Get("{userId}")
853
+ @Security("bearerAuth")
854
+ @Response<ErrorResponse>(404, "User not found")
855
+ public async getUser(@Path() userId: string): Promise<User> {
856
+ throw new Error("Not implemented");
857
+ }
858
+
859
+ /**
860
+ * Update user attributes
861
+ * @param userId User ID
862
+ */
863
+ @Patch("{userId}")
864
+ @Security("bearerAuth")
865
+ @Response<ErrorResponse>(400, "Invalid request")
866
+ @Response<ErrorResponse>(404, "User not found")
867
+ public async updateUser(
868
+ @Path() userId: string,
869
+ @Body() body: UpdateUserRequest,
870
+ ): Promise<User> {
871
+ throw new Error("Not implemented");
872
+ }
873
+
874
+ /**
875
+ * Delete user
876
+ * @param userId User ID
877
+ */
878
+ @Delete("{userId}")
879
+ @Tags("Users", "Admin")
880
+ @Security("bearerAuth")
881
+ @SuccessResponse(204, "Deleted")
882
+ @Response<ErrorResponse>(404, "User not found")
883
+ public async deleteUser(@Path() userId: string): Promise<void> {
884
+ this.setStatus(204);
885
+ }
886
+ }
887
+ ```
888
+
889
+ ### Template 4: Validation & Linting
890
+
891
+ ```bash
892
+ # Install validation tools
893
+ npm install -g @stoplight/spectral-cli
894
+ npm install -g @redocly/cli
895
+
896
+ # Spectral ruleset (.spectral.yaml)
897
+ cat > .spectral.yaml << 'EOF'
898
+ extends: ["spectral:oas", "spectral:asyncapi"]
899
+
900
+ rules:
901
+ # Enforce operation IDs
902
+ operation-operationId: error
903
+
904
+ # Require descriptions
905
+ operation-description: warn
906
+ info-description: error
907
+
908
+ # Naming conventions
909
+ operation-operationId-valid-in-url: true
910
+
911
+ # Security
912
+ operation-security-defined: error
913
+
914
+ # Response codes
915
+ operation-success-response: error
916
+
917
+ # Custom rules
918
+ path-params-snake-case:
919
+ description: Path parameters should be snake_case
920
+ severity: warn
921
+ given: "$.paths[*].parameters[?(@.in == 'path')].name"
922
+ then:
923
+ function: pattern
924
+ functionOptions:
925
+ match: "^[a-z][a-z0-9_]*$"
926
+
927
+ schema-properties-camelCase:
928
+ description: Schema properties should be camelCase
929
+ severity: warn
930
+ given: "$.components.schemas[*].properties[*]~"
931
+ then:
932
+ function: casing
933
+ functionOptions:
934
+ type: camel
935
+ EOF
936
+
937
+ # Run Spectral
938
+ spectral lint openapi.yaml
939
+
940
+ # Redocly config (redocly.yaml)
941
+ cat > redocly.yaml << 'EOF'
942
+ extends:
943
+ - recommended
944
+
945
+ rules:
946
+ no-invalid-media-type-examples: error
947
+ no-invalid-schema-examples: error
948
+ operation-4xx-response: warn
949
+ request-mime-type:
950
+ severity: error
951
+ allowedValues:
952
+ - application/json
953
+ response-mime-type:
954
+ severity: error
955
+ allowedValues:
956
+ - application/json
957
+ - application/problem+json
958
+
959
+ theme:
960
+ openapi:
961
+ generateCodeSamples:
962
+ languages:
963
+ - lang: curl
964
+ - lang: python
965
+ - lang: javascript
966
+ EOF
967
+
968
+ # Run Redocly
969
+ redocly lint openapi.yaml
970
+ redocly bundle openapi.yaml -o bundled.yaml
971
+ redocly preview-docs openapi.yaml
972
+ ```
973
+
974
+ ## SDK Generation
975
+
976
+ ```bash
977
+ # OpenAPI Generator
978
+ npm install -g @openapitools/openapi-generator-cli
979
+
980
+ # Generate TypeScript client
981
+ openapi-generator-cli generate \
982
+ -i openapi.yaml \
983
+ -g typescript-fetch \
984
+ -o ./generated/typescript-client \
985
+ --additional-properties=supportsES6=true,npmName=@myorg/api-client
986
+
987
+ # Generate Python client
988
+ openapi-generator-cli generate \
989
+ -i openapi.yaml \
990
+ -g python \
991
+ -o ./generated/python-client \
992
+ --additional-properties=packageName=api_client
993
+
994
+ # Generate Go client
995
+ openapi-generator-cli generate \
996
+ -i openapi.yaml \
997
+ -g go \
998
+ -o ./generated/go-client
999
+ ```
1000
+
1001
+ ## Best Practices
1002
+
1003
+ ### Do's
1004
+
1005
+ - **Use $ref** - Reuse schemas, parameters, responses
1006
+ - **Add examples** - Real-world values help consumers
1007
+ - **Document errors** - All possible error codes
1008
+ - **Version your API** - In URL or header
1009
+ - **Use semantic versioning** - For spec changes
1010
+
1011
+ ### Don'ts
1012
+
1013
+ - **Don't use generic descriptions** - Be specific
1014
+ - **Don't skip security** - Define all schemes
1015
+ - **Don't forget nullable** - Be explicit about null
1016
+ - **Don't mix styles** - Consistent naming throughout
1017
+ - **Don't hardcode URLs** - Use server variables
1018
+
1019
+ ## Resources
1020
+
1021
+ - [OpenAPI 3.1 Specification](https://spec.openapis.org/oas/v3.1.0)
1022
+ - [Swagger Editor](https://editor.swagger.io/)
1023
+ - [Redocly](https://redocly.com/)
1024
+ - [Spectral](https://stoplight.io/open-source/spectral)