@zimezone/z-command 1.0.1 → 1.1.1

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 (217) hide show
  1. package/README.md +57 -38
  2. package/dist/cli.js +14 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/init.d.ts +1 -7
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +101 -23
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/update.d.ts +11 -0
  9. package/dist/commands/update.d.ts.map +1 -0
  10. package/dist/commands/update.js +88 -0
  11. package/dist/commands/update.js.map +1 -0
  12. package/dist/platforms.d.ts +21 -0
  13. package/dist/platforms.d.ts.map +1 -0
  14. package/dist/platforms.js +137 -0
  15. package/dist/platforms.js.map +1 -0
  16. package/dist/types.d.ts +44 -0
  17. package/dist/types.d.ts.map +1 -0
  18. package/dist/types.js +6 -0
  19. package/dist/types.js.map +1 -0
  20. package/package.json +13 -5
  21. package/templates/agents/api-documenter.agent.md +161 -0
  22. package/templates/agents/architect-review.agent.md +146 -0
  23. package/templates/agents/arm-cortex-expert.agent.md +288 -0
  24. package/templates/agents/backend-architect.agent.md +309 -0
  25. package/templates/agents/backend-security-coder.agent.md +152 -0
  26. package/templates/agents/bash-pro.agent.md +285 -0
  27. package/templates/agents/c-pro.agent.md +35 -0
  28. package/templates/agents/c4-code.agent.md +320 -0
  29. package/templates/agents/c4-component.agent.md +227 -0
  30. package/templates/agents/c4-container.agent.md +248 -0
  31. package/templates/agents/c4-context.agent.md +235 -0
  32. package/templates/agents/conductor-validator.agent.md +245 -0
  33. package/templates/agents/csharp-pro.agent.md +38 -0
  34. package/templates/agents/customer-support.agent.md +148 -0
  35. package/templates/agents/database-admin.agent.md +142 -0
  36. package/templates/agents/database-architect.agent.md +238 -0
  37. package/templates/agents/database-optimizer.agent.md +144 -0
  38. package/templates/agents/debugger.agent.md +30 -0
  39. package/templates/agents/deployment-engineer.agent.md +0 -0
  40. package/templates/agents/devops-troubleshooter.agent.md +138 -0
  41. package/templates/agents/django-pro.agent.md +159 -0
  42. package/templates/agents/docs-architect.agent.md +77 -0
  43. package/templates/agents/dotnet-architect.agent.md +175 -0
  44. package/templates/agents/dx-optimizer.agent.md +63 -0
  45. package/templates/agents/elixir-pro.agent.md +38 -0
  46. package/templates/agents/error-detective.agent.md +32 -0
  47. package/templates/agents/event-sourcing-architect.agent.md +42 -0
  48. package/templates/agents/fastapi-pro.agent.md +171 -0
  49. package/templates/agents/firmware-analyst.agent.md +330 -0
  50. package/templates/agents/frontend-security-coder.agent.md +149 -0
  51. package/templates/agents/haskell-pro.agent.md +37 -0
  52. package/templates/agents/hr-pro.agent.md +105 -0
  53. package/templates/agents/incident-responder.agent.md +190 -0
  54. package/templates/agents/ios-developer.agent.md +198 -0
  55. package/templates/agents/java-pro.agent.md +156 -0
  56. package/templates/agents/javascript-pro.agent.md +35 -0
  57. package/templates/agents/julia-pro.agent.md +187 -0
  58. package/templates/agents/legal-advisor.agent.md +49 -0
  59. package/templates/agents/malware-analyst.agent.md +272 -0
  60. package/templates/agents/mermaid-expert.agent.md +39 -0
  61. package/templates/agents/minecraft-bukkit-pro.agent.md +104 -0
  62. package/templates/agents/mobile-security-coder.agent.md +163 -0
  63. package/templates/agents/monorepo-architect.agent.md +44 -0
  64. package/templates/agents/observability-engineer.agent.md +228 -0
  65. package/templates/agents/performance-engineer.agent.md +167 -0
  66. package/templates/agents/php-pro.agent.md +43 -0
  67. package/templates/agents/posix-shell-pro.agent.md +284 -0
  68. package/templates/agents/quant-analyst.agent.md +32 -0
  69. package/templates/agents/reference-builder.agent.md +167 -0
  70. package/templates/agents/reverse-engineer.agent.md +202 -0
  71. package/templates/agents/risk-manager.agent.md +41 -0
  72. package/templates/agents/ruby-pro.agent.md +35 -0
  73. package/templates/agents/rust-pro.agent.md +156 -0
  74. package/templates/agents/sales-automator.agent.md +35 -0
  75. package/templates/agents/scala-pro.agent.md +60 -0
  76. package/templates/agents/search-specialist.agent.md +59 -0
  77. package/templates/agents/security-auditor.agent.md +138 -0
  78. package/templates/agents/seo-authority-builder.agent.md +116 -0
  79. package/templates/agents/seo-cannibalization-detector.agent.md +103 -0
  80. package/templates/agents/seo-content-auditor.agent.md +63 -0
  81. package/templates/agents/seo-content-planner.agent.md +88 -0
  82. package/templates/agents/seo-content-refresher.agent.md +98 -0
  83. package/templates/agents/seo-content-writer.agent.md +76 -0
  84. package/templates/agents/seo-keyword-strategist.agent.md +75 -0
  85. package/templates/agents/seo-meta-optimizer.agent.md +72 -0
  86. package/templates/agents/seo-snippet-hunter.agent.md +94 -0
  87. package/templates/agents/seo-structure-architect.agent.md +88 -0
  88. package/templates/agents/service-mesh-expert.agent.md +41 -0
  89. package/templates/agents/sql-pro.agent.md +146 -0
  90. package/templates/agents/tdd-orchestrator.agent.md +183 -0
  91. package/templates/agents/temporal-python-pro.agent.md +349 -0
  92. package/templates/agents/terraform-specialist.agent.md +137 -0
  93. package/templates/agents/test-automator.agent.md +203 -0
  94. package/templates/agents/threat-modeling-expert.agent.md +44 -0
  95. package/templates/agents/tutorial-engineer.agent.md +118 -0
  96. package/templates/agents/ui-ux-designer.agent.md +188 -0
  97. package/templates/agents/ui-visual-validator.agent.md +192 -0
  98. package/templates/agents/vector-database-engineer.agent.md +43 -0
  99. package/templates/skills/angular-migration/SKILL.md +410 -0
  100. package/templates/skills/api-design-principles/SKILL.md +528 -0
  101. package/templates/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  102. package/templates/skills/api-design-principles/assets/rest-api-template.py +182 -0
  103. package/templates/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  104. package/templates/skills/api-design-principles/references/rest-best-practices.md +408 -0
  105. package/templates/skills/architecture-decision-records/SKILL.md +428 -0
  106. package/templates/skills/architecture-patterns/SKILL.md +494 -0
  107. package/templates/skills/async-python-patterns/SKILL.md +694 -0
  108. package/templates/skills/auth-implementation-patterns/SKILL.md +634 -0
  109. package/templates/skills/changelog-automation/SKILL.md +552 -0
  110. package/templates/skills/code-review-excellence/SKILL.md +520 -0
  111. package/templates/skills/competitive-landscape/SKILL.md +479 -0
  112. package/templates/skills/context-driven-development/SKILL.md +385 -0
  113. package/templates/skills/cost-optimization/SKILL.md +274 -0
  114. package/templates/skills/cqrs-implementation/SKILL.md +554 -0
  115. package/templates/skills/data-quality-frameworks/SKILL.md +587 -0
  116. package/templates/skills/data-storytelling/SKILL.md +453 -0
  117. package/templates/skills/database-migration/SKILL.md +424 -0
  118. package/templates/skills/dbt-transformation-patterns/SKILL.md +561 -0
  119. package/templates/skills/debugging-strategies/SKILL.md +527 -0
  120. package/templates/skills/defi-protocol-templates/SKILL.md +454 -0
  121. package/templates/skills/dependency-upgrade/SKILL.md +409 -0
  122. package/templates/skills/deployment-pipeline-design/SKILL.md +359 -0
  123. package/templates/skills/distributed-tracing/SKILL.md +438 -0
  124. package/templates/skills/dotnet-backend-patterns/SKILL.md +815 -0
  125. package/templates/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
  126. package/templates/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
  127. package/templates/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
  128. package/templates/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
  129. package/templates/skills/e2e-testing-patterns/SKILL.md +547 -0
  130. package/templates/skills/employment-contract-templates/SKILL.md +507 -0
  131. package/templates/skills/error-handling-patterns/SKILL.md +636 -0
  132. package/templates/skills/event-store-design/SKILL.md +437 -0
  133. package/templates/skills/fastapi-templates/SKILL.md +567 -0
  134. package/templates/skills/git-advanced-workflows/SKILL.md +400 -0
  135. package/templates/skills/github-actions-templates/SKILL.md +333 -0
  136. package/templates/skills/go-concurrency-patterns/SKILL.md +655 -0
  137. package/templates/skills/grafana-dashboards/SKILL.md +369 -0
  138. package/templates/skills/helm-chart-scaffolding/SKILL.md +544 -0
  139. package/templates/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
  140. package/templates/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
  141. package/templates/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
  142. package/templates/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
  143. package/templates/skills/javascript-testing-patterns/SKILL.md +1025 -0
  144. package/templates/skills/langchain-architecture/SKILL.md +338 -0
  145. package/templates/skills/llm-evaluation/SKILL.md +471 -0
  146. package/templates/skills/microservices-patterns/SKILL.md +595 -0
  147. package/templates/skills/modern-javascript-patterns/SKILL.md +911 -0
  148. package/templates/skills/monorepo-management/SKILL.md +622 -0
  149. package/templates/skills/nextjs-app-router-patterns/SKILL.md +544 -0
  150. package/templates/skills/nodejs-backend-patterns/SKILL.md +1020 -0
  151. package/templates/skills/nx-workspace-patterns/SKILL.md +452 -0
  152. package/templates/skills/openapi-spec-generation/SKILL.md +1028 -0
  153. package/templates/skills/paypal-integration/SKILL.md +467 -0
  154. package/templates/skills/pci-compliance/SKILL.md +466 -0
  155. package/templates/skills/postgresql/SKILL.md +204 -0
  156. package/templates/skills/projection-patterns/SKILL.md +490 -0
  157. package/templates/skills/prometheus-configuration/SKILL.md +392 -0
  158. package/templates/skills/prompt-engineering-patterns/SKILL.md +201 -0
  159. package/templates/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
  160. package/templates/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
  161. package/templates/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
  162. package/templates/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
  163. package/templates/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
  164. package/templates/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
  165. package/templates/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
  166. package/templates/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
  167. package/templates/skills/python-packaging/SKILL.md +870 -0
  168. package/templates/skills/python-performance-optimization/SKILL.md +869 -0
  169. package/templates/skills/python-testing-patterns/SKILL.md +907 -0
  170. package/templates/skills/rag-implementation/SKILL.md +403 -0
  171. package/templates/skills/react-modernization/SKILL.md +513 -0
  172. package/templates/skills/react-native-architecture/SKILL.md +671 -0
  173. package/templates/skills/react-state-management/SKILL.md +429 -0
  174. package/templates/skills/risk-metrics-calculation/SKILL.md +555 -0
  175. package/templates/skills/rust-async-patterns/SKILL.md +517 -0
  176. package/templates/skills/secrets-management/SKILL.md +346 -0
  177. package/templates/skills/security-requirement-extraction/SKILL.md +677 -0
  178. package/templates/skills/shellcheck-configuration/SKILL.md +454 -0
  179. package/templates/skills/similarity-search-patterns/SKILL.md +558 -0
  180. package/templates/skills/slo-implementation/SKILL.md +329 -0
  181. package/templates/skills/sql-optimization-patterns/SKILL.md +493 -0
  182. package/templates/skills/stripe-integration/SKILL.md +442 -0
  183. package/templates/skills/tailwind-design-system/SKILL.md +666 -0
  184. package/templates/skills/temporal-python-testing/SKILL.md +158 -0
  185. package/templates/skills/temporal-python-testing/resources/integration-testing.md +455 -0
  186. package/templates/skills/temporal-python-testing/resources/local-setup.md +553 -0
  187. package/templates/skills/temporal-python-testing/resources/replay-testing.md +462 -0
  188. package/templates/skills/temporal-python-testing/resources/unit-testing.md +328 -0
  189. package/templates/skills/terraform-module-library/SKILL.md +249 -0
  190. package/templates/skills/terraform-module-library/references/aws-modules.md +63 -0
  191. package/templates/skills/threat-mitigation-mapping/SKILL.md +745 -0
  192. package/templates/skills/track-management/SKILL.md +593 -0
  193. package/templates/skills/typescript-advanced-types/SKILL.md +717 -0
  194. package/templates/skills/ui-ux-pro-max/SKILL.md +352 -0
  195. package/templates/skills/ui-ux-pro-max/data/charts.csv +26 -0
  196. package/templates/skills/ui-ux-pro-max/data/colors.csv +97 -0
  197. package/templates/skills/ui-ux-pro-max/data/icons.csv +101 -0
  198. package/templates/skills/ui-ux-pro-max/data/landing.csv +31 -0
  199. package/templates/skills/ui-ux-pro-max/data/products.csv +97 -0
  200. package/templates/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  201. package/templates/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  202. package/templates/skills/ui-ux-pro-max/data/styles.csv +59 -0
  203. package/templates/skills/ui-ux-pro-max/data/typography.csv +58 -0
  204. package/templates/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  205. package/templates/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  206. package/templates/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  207. package/templates/skills/ui-ux-pro-max/scripts/core.py +258 -0
  208. package/templates/skills/ui-ux-pro-max/scripts/design_system.py +547 -0
  209. package/templates/skills/ui-ux-pro-max/scripts/search.py +76 -0
  210. package/templates/skills/uv-package-manager/SKILL.md +831 -0
  211. package/templates/skills/vector-index-tuning/SKILL.md +521 -0
  212. package/templates/skills/wcag-audit-patterns/SKILL.md +555 -0
  213. package/templates/skills/workflow-orchestration-patterns/SKILL.md +316 -0
  214. package/templates/skills/workflow-patterns/SKILL.md +623 -0
  215. package/templates/agents/game-developer.agent.md +0 -57
  216. package/templates/agents/kubernetes-specialist.agent.md +0 -56
  217. package/templates/agents/market-researcher.agent.md +0 -47
@@ -0,0 +1,1028 @@
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(
844
+ @Body() body: CreateUserRequest
845
+ ): Promise<User> {
846
+ this.setStatus(201);
847
+ throw new Error("Not implemented");
848
+ }
849
+
850
+ /**
851
+ * Get user by ID
852
+ * @param userId User ID
853
+ */
854
+ @Get("{userId}")
855
+ @Security("bearerAuth")
856
+ @Response<ErrorResponse>(404, "User not found")
857
+ public async getUser(
858
+ @Path() userId: string
859
+ ): Promise<User> {
860
+ throw new Error("Not implemented");
861
+ }
862
+
863
+ /**
864
+ * Update user attributes
865
+ * @param userId User ID
866
+ */
867
+ @Patch("{userId}")
868
+ @Security("bearerAuth")
869
+ @Response<ErrorResponse>(400, "Invalid request")
870
+ @Response<ErrorResponse>(404, "User not found")
871
+ public async updateUser(
872
+ @Path() userId: string,
873
+ @Body() body: UpdateUserRequest
874
+ ): Promise<User> {
875
+ throw new Error("Not implemented");
876
+ }
877
+
878
+ /**
879
+ * Delete user
880
+ * @param userId User ID
881
+ */
882
+ @Delete("{userId}")
883
+ @Tags("Users", "Admin")
884
+ @Security("bearerAuth")
885
+ @SuccessResponse(204, "Deleted")
886
+ @Response<ErrorResponse>(404, "User not found")
887
+ public async deleteUser(
888
+ @Path() userId: string
889
+ ): Promise<void> {
890
+ this.setStatus(204);
891
+ }
892
+ }
893
+ ```
894
+
895
+ ### Template 4: Validation & Linting
896
+
897
+ ```bash
898
+ # Install validation tools
899
+ npm install -g @stoplight/spectral-cli
900
+ npm install -g @redocly/cli
901
+
902
+ # Spectral ruleset (.spectral.yaml)
903
+ cat > .spectral.yaml << 'EOF'
904
+ extends: ["spectral:oas", "spectral:asyncapi"]
905
+
906
+ rules:
907
+ # Enforce operation IDs
908
+ operation-operationId: error
909
+
910
+ # Require descriptions
911
+ operation-description: warn
912
+ info-description: error
913
+
914
+ # Naming conventions
915
+ operation-operationId-valid-in-url: true
916
+
917
+ # Security
918
+ operation-security-defined: error
919
+
920
+ # Response codes
921
+ operation-success-response: error
922
+
923
+ # Custom rules
924
+ path-params-snake-case:
925
+ description: Path parameters should be snake_case
926
+ severity: warn
927
+ given: "$.paths[*].parameters[?(@.in == 'path')].name"
928
+ then:
929
+ function: pattern
930
+ functionOptions:
931
+ match: "^[a-z][a-z0-9_]*$"
932
+
933
+ schema-properties-camelCase:
934
+ description: Schema properties should be camelCase
935
+ severity: warn
936
+ given: "$.components.schemas[*].properties[*]~"
937
+ then:
938
+ function: casing
939
+ functionOptions:
940
+ type: camel
941
+ EOF
942
+
943
+ # Run Spectral
944
+ spectral lint openapi.yaml
945
+
946
+ # Redocly config (redocly.yaml)
947
+ cat > redocly.yaml << 'EOF'
948
+ extends:
949
+ - recommended
950
+
951
+ rules:
952
+ no-invalid-media-type-examples: error
953
+ no-invalid-schema-examples: error
954
+ operation-4xx-response: warn
955
+ request-mime-type:
956
+ severity: error
957
+ allowedValues:
958
+ - application/json
959
+ response-mime-type:
960
+ severity: error
961
+ allowedValues:
962
+ - application/json
963
+ - application/problem+json
964
+
965
+ theme:
966
+ openapi:
967
+ generateCodeSamples:
968
+ languages:
969
+ - lang: curl
970
+ - lang: python
971
+ - lang: javascript
972
+ EOF
973
+
974
+ # Run Redocly
975
+ redocly lint openapi.yaml
976
+ redocly bundle openapi.yaml -o bundled.yaml
977
+ redocly preview-docs openapi.yaml
978
+ ```
979
+
980
+ ## SDK Generation
981
+
982
+ ```bash
983
+ # OpenAPI Generator
984
+ npm install -g @openapitools/openapi-generator-cli
985
+
986
+ # Generate TypeScript client
987
+ openapi-generator-cli generate \
988
+ -i openapi.yaml \
989
+ -g typescript-fetch \
990
+ -o ./generated/typescript-client \
991
+ --additional-properties=supportsES6=true,npmName=@myorg/api-client
992
+
993
+ # Generate Python client
994
+ openapi-generator-cli generate \
995
+ -i openapi.yaml \
996
+ -g python \
997
+ -o ./generated/python-client \
998
+ --additional-properties=packageName=api_client
999
+
1000
+ # Generate Go client
1001
+ openapi-generator-cli generate \
1002
+ -i openapi.yaml \
1003
+ -g go \
1004
+ -o ./generated/go-client
1005
+ ```
1006
+
1007
+ ## Best Practices
1008
+
1009
+ ### Do's
1010
+ - **Use $ref** - Reuse schemas, parameters, responses
1011
+ - **Add examples** - Real-world values help consumers
1012
+ - **Document errors** - All possible error codes
1013
+ - **Version your API** - In URL or header
1014
+ - **Use semantic versioning** - For spec changes
1015
+
1016
+ ### Don'ts
1017
+ - **Don't use generic descriptions** - Be specific
1018
+ - **Don't skip security** - Define all schemes
1019
+ - **Don't forget nullable** - Be explicit about null
1020
+ - **Don't mix styles** - Consistent naming throughout
1021
+ - **Don't hardcode URLs** - Use server variables
1022
+
1023
+ ## Resources
1024
+
1025
+ - [OpenAPI 3.1 Specification](https://spec.openapis.org/oas/v3.1.0)
1026
+ - [Swagger Editor](https://editor.swagger.io/)
1027
+ - [Redocly](https://redocly.com/)
1028
+ - [Spectral](https://stoplight.io/open-source/spectral)