@documentation-robotics/cli 0.1.0 → 0.1.5
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/LICENSE +21 -0
- package/README.md +466 -693
- package/dist/analysis/data-model-analyzer.js +189 -0
- package/dist/analysis/data-model-analyzer.js.map +7 -0
- package/dist/analysis/index.js +3 -0
- package/dist/analysis/index.js.map +7 -0
- package/dist/analysis/relationship-classifier.js +181 -0
- package/dist/analysis/relationship-classifier.js.map +7 -0
- package/dist/analyzers/base-analyzer.js +1 -0
- package/dist/analyzers/base-analyzer.js.map +7 -0
- package/dist/analyzers/call-graph-utils.js +39 -0
- package/dist/analyzers/call-graph-utils.js.map +7 -0
- package/dist/analyzers/cbm-analyzer.js +1205 -0
- package/dist/analyzers/cbm-analyzer.js.map +7 -0
- package/dist/analyzers/heuristic-utils.js +55 -0
- package/dist/analyzers/heuristic-utils.js.map +7 -0
- package/dist/analyzers/mapping-loader.js +146 -0
- package/dist/analyzers/mapping-loader.js.map +7 -0
- package/dist/analyzers/registry.js +124 -0
- package/dist/analyzers/registry.js.map +7 -0
- package/dist/analyzers/session-state.js +176 -0
- package/dist/analyzers/session-state.js.map +7 -0
- package/dist/analyzers/stdio-client.js +206 -0
- package/dist/analyzers/stdio-client.js.map +7 -0
- package/dist/analyzers/types.js +15 -0
- package/dist/analyzers/types.js.map +7 -0
- package/dist/analyzers/verify-engine.js +209 -0
- package/dist/analyzers/verify-engine.js.map +7 -0
- package/dist/analyzers/verify-ignore.js +130 -0
- package/dist/analyzers/verify-ignore.js.map +7 -0
- package/dist/analyzers/version.js +8 -0
- package/dist/analyzers/version.js.map +7 -0
- package/dist/audit/ai/runner.js +41 -0
- package/dist/audit/ai/runner.js.map +7 -0
- package/dist/audit/differential-analyzer.js +183 -0
- package/dist/audit/differential-analyzer.js.map +7 -0
- package/dist/audit/index.js +32 -0
- package/dist/audit/index.js.map +7 -0
- package/dist/audit/nodes/ai/evaluator.js +49 -0
- package/dist/audit/nodes/ai/evaluator.js.map +7 -0
- package/dist/audit/nodes/ai/parser.js +55 -0
- package/dist/audit/nodes/ai/parser.js.map +7 -0
- package/dist/audit/nodes/ai/prompts.js +103 -0
- package/dist/audit/nodes/ai/prompts.js.map +7 -0
- package/dist/audit/nodes/analysis/node-completeness-checker.js +32 -0
- package/dist/audit/nodes/analysis/node-completeness-checker.js.map +7 -0
- package/dist/audit/nodes/analysis/node-definition-analyzer.js +47 -0
- package/dist/audit/nodes/analysis/node-definition-analyzer.js.map +7 -0
- package/dist/audit/nodes/analysis/node-overlap-detector.js +79 -0
- package/dist/audit/nodes/analysis/node-overlap-detector.js.map +7 -0
- package/dist/audit/nodes/model/orchestrator.js +82 -0
- package/dist/audit/nodes/model/orchestrator.js.map +7 -0
- package/dist/audit/nodes/spec/loader.js +116 -0
- package/dist/audit/nodes/spec/loader.js.map +7 -0
- package/dist/audit/nodes/spec/orchestrator.js +68 -0
- package/dist/audit/nodes/spec/orchestrator.js.map +7 -0
- package/dist/audit/nodes/types.js +1 -0
- package/dist/audit/nodes/types.js.map +7 -0
- package/dist/audit/pipeline/index.js +5 -0
- package/dist/audit/pipeline/index.js.map +7 -0
- package/dist/audit/pipeline/pipeline-orchestrator.js +218 -0
- package/dist/audit/pipeline/pipeline-orchestrator.js.map +7 -0
- package/dist/audit/relationships/ai/evaluator.js +235 -0
- package/dist/audit/relationships/ai/evaluator.js.map +7 -0
- package/dist/audit/relationships/ai/parser.js +197 -0
- package/dist/audit/relationships/ai/parser.js.map +7 -0
- package/dist/audit/relationships/ai/prompts.js +274 -0
- package/dist/audit/relationships/ai/prompts.js.map +7 -0
- package/dist/audit/relationships/analysis/balance-assessor.js +115 -0
- package/dist/audit/relationships/analysis/balance-assessor.js.map +7 -0
- package/dist/audit/relationships/analysis/coverage-analyzer.js +99 -0
- package/dist/audit/relationships/analysis/coverage-analyzer.js.map +7 -0
- package/dist/audit/relationships/analysis/duplicate-detector.js +95 -0
- package/dist/audit/relationships/analysis/duplicate-detector.js.map +7 -0
- package/dist/audit/relationships/analysis/gap-analyzer.js +99 -0
- package/dist/audit/relationships/analysis/gap-analyzer.js.map +7 -0
- package/dist/audit/relationships/analysis/layer-templates.js +294 -0
- package/dist/audit/relationships/analysis/layer-templates.js.map +7 -0
- package/dist/audit/relationships/graph/connectivity.js +129 -0
- package/dist/audit/relationships/graph/connectivity.js.map +7 -0
- package/dist/audit/relationships/graph/relationship-graph.js +179 -0
- package/dist/audit/relationships/graph/relationship-graph.js.map +7 -0
- package/dist/audit/relationships/model/balance-assessor.js +49 -0
- package/dist/audit/relationships/model/balance-assessor.js.map +7 -0
- package/dist/audit/relationships/model/coverage-analyzer.js +34 -0
- package/dist/audit/relationships/model/coverage-analyzer.js.map +7 -0
- package/dist/audit/relationships/model/duplicate-detector.js +68 -0
- package/dist/audit/relationships/model/duplicate-detector.js.map +7 -0
- package/dist/audit/relationships/model/gap-analyzer.js +41 -0
- package/dist/audit/relationships/model/gap-analyzer.js.map +7 -0
- package/dist/audit/relationships/model/orchestrator.js +126 -0
- package/dist/audit/relationships/model/orchestrator.js.map +7 -0
- package/dist/audit/relationships/spec/orchestrator.js +157 -0
- package/dist/audit/relationships/spec/orchestrator.js.map +7 -0
- package/dist/audit/reports/index.js +5 -0
- package/dist/audit/reports/index.js.map +7 -0
- package/dist/audit/reports/report-generator.js +118 -0
- package/dist/audit/reports/report-generator.js.map +7 -0
- package/dist/audit/snapshot-storage.js +163 -0
- package/dist/audit/snapshot-storage.js.map +7 -0
- package/dist/audit/types.js +21 -0
- package/dist/audit/types.js.map +7 -0
- package/dist/cli.js +223 -92
- package/dist/cli.js.map +3 -3
- package/dist/coding-agents/agents/claude-code.js +147 -0
- package/dist/coding-agents/agents/claude-code.js.map +7 -0
- package/dist/coding-agents/agents/index.js +5 -0
- package/dist/coding-agents/agents/index.js.map +7 -0
- package/dist/coding-agents/agents/types.js +1 -0
- package/dist/coding-agents/agents/types.js.map +7 -0
- package/dist/coding-agents/base-chat-client.js +45 -0
- package/dist/coding-agents/base-chat-client.js.map +7 -0
- package/dist/coding-agents/chat-utils.js +23 -0
- package/dist/coding-agents/chat-utils.js.map +7 -0
- package/dist/coding-agents/claude-code-client.js +246 -0
- package/dist/coding-agents/claude-code-client.js.map +7 -0
- package/dist/coding-agents/copilot-client.js +209 -0
- package/dist/coding-agents/copilot-client.js.map +7 -0
- package/dist/commands/add.js +95 -33
- package/dist/commands/add.js.map +2 -2
- package/dist/commands/analyzer.js +511 -0
- package/dist/commands/analyzer.js.map +7 -0
- package/dist/commands/audit-diff.js +49 -0
- package/dist/commands/audit-diff.js.map +7 -0
- package/dist/commands/audit-snapshots.js +62 -0
- package/dist/commands/audit-snapshots.js.map +7 -0
- package/dist/commands/audit.js +81 -0
- package/dist/commands/audit.js.map +7 -0
- package/dist/commands/catalog.js +248 -0
- package/dist/commands/catalog.js.map +7 -0
- package/dist/commands/changeset.js +577 -66
- package/dist/commands/changeset.js.map +2 -2
- package/dist/commands/chat.js +106 -83
- package/dist/commands/chat.js.map +2 -2
- package/dist/commands/claude.js +74 -0
- package/dist/commands/claude.js.map +7 -0
- package/dist/commands/conformance.js +71 -68
- package/dist/commands/conformance.js.map +2 -2
- package/dist/commands/copilot.js +75 -0
- package/dist/commands/copilot.js.map +7 -0
- package/dist/commands/delete.js +125 -11
- package/dist/commands/delete.js.map +3 -3
- package/dist/commands/discover-logic.js +44 -0
- package/dist/commands/discover-logic.js.map +7 -0
- package/dist/commands/docs.js +87 -0
- package/dist/commands/docs.js.map +7 -0
- package/dist/commands/element.js +14 -20
- package/dist/commands/element.js.map +2 -2
- package/dist/commands/export.js +13 -3
- package/dist/commands/export.js.map +2 -2
- package/dist/commands/import.js +51 -0
- package/dist/commands/import.js.map +7 -0
- package/dist/commands/info.js +30 -24
- package/dist/commands/info.js.map +2 -2
- package/dist/commands/init.js +27 -11
- package/dist/commands/init.js.map +2 -2
- package/dist/commands/list.js +63 -13
- package/dist/commands/list.js.map +3 -3
- package/dist/commands/relationship.js +225 -37
- package/dist/commands/relationship.js.map +2 -2
- package/dist/commands/report.js +54 -0
- package/dist/commands/report.js.map +7 -0
- package/dist/commands/reports.js +45 -0
- package/dist/commands/reports.js.map +7 -0
- package/dist/commands/schema.js +135 -0
- package/dist/commands/schema.js.map +7 -0
- package/dist/commands/search.js +40 -12
- package/dist/commands/search.js.map +2 -2
- package/dist/commands/show.js +58 -27
- package/dist/commands/show.js.map +2 -2
- package/dist/commands/stats.js +35 -0
- package/dist/commands/stats.js.map +7 -0
- package/dist/commands/trace.js +39 -16
- package/dist/commands/trace.js.map +2 -2
- package/dist/commands/update.js +141 -14
- package/dist/commands/update.js.map +2 -2
- package/dist/commands/upgrade.js +210 -46
- package/dist/commands/upgrade.js.map +3 -3
- package/dist/commands/validate.js +142 -23
- package/dist/commands/validate.js.map +3 -3
- package/dist/commands/version.js +8 -12
- package/dist/commands/version.js.map +2 -2
- package/dist/commands/visualize.js +155 -25
- package/dist/commands/visualize.js.map +2 -2
- package/dist/core/base-snapshot-manager.js +84 -0
- package/dist/core/base-snapshot-manager.js.map +7 -0
- package/dist/core/changeset-exporter.js +305 -0
- package/dist/core/changeset-exporter.js.map +7 -0
- package/dist/core/changeset-validator.js +41 -0
- package/dist/core/changeset-validator.js.map +7 -0
- package/dist/core/changeset.js +88 -173
- package/dist/core/changeset.js.map +2 -2
- package/dist/core/dependency-tracker.js +4 -2
- package/dist/core/dependency-tracker.js.map +2 -2
- package/dist/core/element.js +98 -27
- package/dist/core/element.js.map +2 -2
- package/dist/core/golden-copy-cache.js +290 -0
- package/dist/core/golden-copy-cache.js.map +7 -0
- package/dist/core/graph-model.js +266 -0
- package/dist/core/graph-model.js.map +7 -0
- package/dist/core/layer.js +159 -16
- package/dist/core/layer.js.map +2 -2
- package/dist/core/layers.js +32 -0
- package/dist/core/layers.js.map +7 -0
- package/dist/core/manifest.js +32 -11
- package/dist/core/manifest.js.map +2 -2
- package/dist/core/migration-registry.js +56 -1
- package/dist/core/migration-registry.js.map +2 -2
- package/dist/core/model.js +424 -217
- package/dist/core/model.js.map +3 -3
- package/dist/core/mutation-handler.js +179 -0
- package/dist/core/mutation-handler.js.map +7 -0
- package/dist/core/reference-registry.js +29 -21
- package/dist/core/reference-registry.js.map +2 -2
- package/dist/core/relationship-catalog.js +189 -0
- package/dist/core/relationship-catalog.js.map +7 -0
- package/dist/core/relationship-registry.js.map +2 -2
- package/dist/core/relationships.js.map +1 -1
- package/dist/core/report-data-model.js +285 -0
- package/dist/core/report-data-model.js.map +7 -0
- package/dist/core/spec-data-service.js +185 -0
- package/dist/core/spec-data-service.js.map +7 -0
- package/dist/core/spec-loader-types.js +1 -0
- package/dist/core/spec-loader-types.js.map +7 -0
- package/dist/core/spec-loader.js +234 -0
- package/dist/core/spec-loader.js.map +7 -0
- package/dist/core/staged-changeset-storage.js +282 -0
- package/dist/core/staged-changeset-storage.js.map +7 -0
- package/dist/core/staging-area.js +1002 -0
- package/dist/core/staging-area.js.map +7 -0
- package/dist/core/stats-collector.js +169 -0
- package/dist/core/stats-collector.js.map +7 -0
- package/dist/core/virtual-projection.js +443 -0
- package/dist/core/virtual-projection.js.map +7 -0
- package/dist/export/archimate-exporter.js +99 -60
- package/dist/export/archimate-exporter.js.map +2 -2
- package/dist/export/audit-formatters.js +479 -0
- package/dist/export/audit-formatters.js.map +7 -0
- package/dist/export/diff-formatters.js +99 -0
- package/dist/export/diff-formatters.js.map +7 -0
- package/dist/export/export-manager.js.map +2 -2
- package/dist/export/graphml-exporter.js +44 -27
- package/dist/export/graphml-exporter.js.map +2 -2
- package/dist/export/index.js +4 -0
- package/dist/export/index.js.map +2 -2
- package/dist/export/json-schema-exporter.js +55 -42
- package/dist/export/json-schema-exporter.js.map +2 -2
- package/dist/export/markdown-exporter.js +92 -70
- package/dist/export/markdown-exporter.js.map +2 -2
- package/dist/export/markdown-generator.js +248 -0
- package/dist/export/markdown-generator.js.map +7 -0
- package/dist/export/markdown-utils.js +30 -0
- package/dist/export/markdown-utils.js.map +7 -0
- package/dist/export/mermaid-markdown-exporter.js +37 -0
- package/dist/export/mermaid-markdown-exporter.js.map +7 -0
- package/dist/export/openapi-exporter.js +119 -71
- package/dist/export/openapi-exporter.js.map +2 -2
- package/dist/export/plantuml-exporter.js +104 -39
- package/dist/export/plantuml-exporter.js.map +2 -2
- package/dist/export/report-formatters.js +111 -0
- package/dist/export/report-formatters.js.map +7 -0
- package/dist/export/stats-formatters.js +98 -0
- package/dist/export/stats-formatters.js.map +7 -0
- package/dist/export/types.js +2 -14
- package/dist/export/types.js.map +2 -2
- package/dist/export/verify-formatters.js +153 -0
- package/dist/export/verify-formatters.js.map +7 -0
- package/dist/generated/compiled-validators.js +17 -0
- package/dist/generated/compiled-validators.js.map +7 -0
- package/dist/generated/index.js +31 -0
- package/dist/generated/index.js.map +7 -0
- package/dist/generated/layer-registry.js +190 -0
- package/dist/generated/layer-registry.js.map +7 -0
- package/dist/generated/layer-types.js +7 -0
- package/dist/generated/layer-types.js.map +7 -0
- package/dist/generated/node-types.js +1719 -0
- package/dist/generated/node-types.js.map +7 -0
- package/dist/generated/relationship-index.js +14552 -0
- package/dist/generated/relationship-index.js.map +7 -0
- package/dist/import/archimate-importer.js +166 -0
- package/dist/import/archimate-importer.js.map +7 -0
- package/dist/import/index.js +47 -0
- package/dist/import/index.js.map +7 -0
- package/dist/import/openapi-importer.js +143 -0
- package/dist/import/openapi-importer.js.map +7 -0
- package/dist/import/types.js +1 -0
- package/dist/import/types.js.map +7 -0
- package/dist/integrations/base-manager.js +311 -0
- package/dist/integrations/base-manager.js.map +7 -0
- package/dist/integrations/claude-manager.js +360 -0
- package/dist/integrations/claude-manager.js.map +7 -0
- package/dist/integrations/claude_code/agents/dr-advisor.md +253 -0
- package/dist/integrations/claude_code/agents/dr-architect.md +278 -0
- package/dist/integrations/claude_code/agents/dr-extractor.md +286 -0
- package/dist/integrations/claude_code/commands/dr-changeset.md +657 -0
- package/dist/integrations/claude_code/commands/dr-design.md +373 -0
- package/dist/integrations/claude_code/commands/dr-info.md +132 -0
- package/dist/integrations/claude_code/commands/dr-init.md +251 -0
- package/dist/integrations/claude_code/commands/dr-map.md +936 -0
- package/dist/integrations/claude_code/commands/dr-model.md +493 -0
- package/dist/integrations/claude_code/commands/dr-relate.md +814 -0
- package/dist/integrations/claude_code/commands/dr-sync.md +279 -0
- package/dist/integrations/claude_code/commands/dr-validate.md +654 -0
- package/dist/integrations/claude_code/commands/dr-verify.md +559 -0
- package/dist/integrations/claude_code/docs/END_TO_END_WALKTHROUGH.md +903 -0
- package/dist/integrations/claude_code/docs/QUICK_START.md +271 -0
- package/dist/integrations/claude_code/docs/README.md +347 -0
- package/dist/integrations/claude_code/skills/dr_01_motivation_layer/SKILL.md +550 -0
- package/dist/integrations/claude_code/skills/dr_02_business_layer/SKILL.md +620 -0
- package/dist/integrations/claude_code/skills/dr_03_security_layer/SKILL.md +642 -0
- package/dist/integrations/claude_code/skills/dr_04_application_layer/SKILL.md +911 -0
- package/dist/integrations/claude_code/skills/dr_05_technology_layer/SKILL.md +836 -0
- package/dist/integrations/claude_code/skills/dr_06_api_layer/SKILL.md +933 -0
- package/dist/integrations/claude_code/skills/dr_07_data_model_layer/SKILL.md +210 -0
- package/dist/integrations/claude_code/skills/dr_08_dataset_layer/SKILL.md +319 -0
- package/dist/integrations/claude_code/skills/dr_09_ux_layer/SKILL.md +319 -0
- package/dist/integrations/claude_code/skills/dr_10_navigation_layer/SKILL.md +318 -0
- package/dist/integrations/claude_code/skills/dr_11_apm_layer/SKILL.md +273 -0
- package/dist/integrations/claude_code/skills/dr_12_testing_layer/SKILL.md +273 -0
- package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +187 -0
- package/dist/integrations/claude_code/skills/dr_codebase_memory/SKILL.md +590 -0
- package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +295 -0
- package/dist/integrations/copilot-manager.js +328 -0
- package/dist/integrations/copilot-manager.js.map +7 -0
- package/dist/integrations/github_copilot/agents/dr-advisor.md +243 -0
- package/dist/integrations/github_copilot/agents/dr-architect.md +1567 -0
- package/dist/integrations/github_copilot/skills/dr_01_motivation_layer/SKILL.md +491 -0
- package/dist/integrations/github_copilot/skills/dr_02_business_layer/SKILL.md +539 -0
- package/dist/integrations/github_copilot/skills/dr_03_security_layer/SKILL.md +667 -0
- package/dist/integrations/github_copilot/skills/dr_04_application_layer/SKILL.md +670 -0
- package/dist/integrations/github_copilot/skills/dr_05_technology_layer/SKILL.md +660 -0
- package/dist/integrations/github_copilot/skills/dr_06_api_layer/SKILL.md +855 -0
- package/dist/integrations/github_copilot/skills/dr_07_data_model_layer/SKILL.md +171 -0
- package/dist/integrations/github_copilot/skills/dr_08_dataset_layer/SKILL.md +216 -0
- package/dist/integrations/github_copilot/skills/dr_09_ux_layer/SKILL.md +230 -0
- package/dist/integrations/github_copilot/skills/dr_10_navigation_layer/SKILL.md +228 -0
- package/dist/integrations/github_copilot/skills/dr_11_apm_layer/SKILL.md +234 -0
- package/dist/integrations/github_copilot/skills/dr_12_testing_layer/SKILL.md +230 -0
- package/dist/integrations/github_copilot/skills/dr_changeset_reviewer/SKILL.md +187 -0
- package/dist/integrations/hash-utils.js +51 -0
- package/dist/integrations/hash-utils.js.map +7 -0
- package/dist/integrations/types.js +16 -0
- package/dist/integrations/types.js.map +7 -0
- package/dist/reports/model-layer-report-generator.js +278 -0
- package/dist/reports/model-layer-report-generator.js.map +7 -0
- package/dist/reports/model-report-data.js +57 -0
- package/dist/reports/model-report-data.js.map +7 -0
- package/dist/reports/model-report-orchestrator.js +103 -0
- package/dist/reports/model-report-orchestrator.js.map +7 -0
- package/dist/schemas/bundled/analyzers/cbm.json +595 -0
- package/dist/schemas/bundled/analyzers/manifest.json +9 -0
- package/dist/schemas/bundled/api.json +3411 -0
- package/dist/schemas/bundled/apm.json +2371 -0
- package/dist/schemas/bundled/application.json +1253 -0
- package/dist/schemas/bundled/base.json +1622 -0
- package/dist/schemas/bundled/business.json +1279 -0
- package/dist/schemas/bundled/data-model.json +1298 -0
- package/dist/schemas/bundled/data-store.json +2025 -0
- package/dist/schemas/bundled/manifest.json +93 -0
- package/dist/schemas/bundled/motivation.json +1360 -0
- package/dist/schemas/bundled/navigation.json +1874 -0
- package/dist/schemas/bundled/security.json +3488 -0
- package/dist/schemas/bundled/technology.json +2067 -0
- package/dist/schemas/bundled/testing.json +3120 -0
- package/dist/schemas/bundled/ux.json +3592 -0
- package/dist/server/schemas.js +202 -0
- package/dist/server/schemas.js.map +7 -0
- package/dist/server/server.js +1336 -252
- package/dist/server/server.js.map +3 -3
- package/dist/server/telemetry-middleware.js +22 -15
- package/dist/server/telemetry-middleware.js.map +2 -2
- package/dist/server-entry.js +65 -0
- package/dist/server-entry.js.map +7 -0
- package/dist/telemetry/config.js +89 -0
- package/dist/telemetry/config.js.map +7 -0
- package/dist/telemetry/console-interceptor.js.map +1 -1
- package/dist/telemetry/detect.js +24 -0
- package/dist/telemetry/detect.js.map +7 -0
- package/dist/telemetry/fetch-otlp-exporter.js +112 -0
- package/dist/telemetry/fetch-otlp-exporter.js.map +7 -0
- package/dist/telemetry/index.js +153 -3
- package/dist/telemetry/index.js.map +2 -2
- package/dist/telemetry/resilient-exporter.js +22 -8
- package/dist/telemetry/resilient-exporter.js.map +2 -2
- package/dist/telemetry/resilient-log-exporter.js +17 -8
- package/dist/telemetry/resilient-log-exporter.js.map +2 -2
- package/dist/telemetry/test-instrumentation.js.map +2 -2
- package/dist/types/index.js +84 -0
- package/dist/types/index.js.map +3 -3
- package/dist/types/source-reference.js +1 -0
- package/dist/types/source-reference.js.map +7 -0
- package/dist/utils/chat-logger.js +292 -0
- package/dist/utils/chat-logger.js.map +7 -0
- package/dist/utils/claude-stream.js +8 -0
- package/dist/utils/claude-stream.js.map +7 -0
- package/dist/utils/date-utils.js +7 -0
- package/dist/utils/date-utils.js.map +7 -0
- package/dist/utils/element-utils.js.map +1 -1
- package/dist/utils/errors.js +88 -15
- package/dist/utils/errors.js.map +3 -3
- package/dist/utils/export-python-annotations.js +82 -0
- package/dist/utils/export-python-annotations.js.map +7 -0
- package/dist/utils/file-io.js +7 -2
- package/dist/utils/file-io.js.map +2 -2
- package/dist/utils/file-lock.js +156 -0
- package/dist/utils/file-lock.js.map +7 -0
- package/dist/utils/id-generator.js +18 -0
- package/dist/utils/id-generator.js.map +7 -0
- package/dist/utils/layer-name-formatter.js +16 -0
- package/dist/utils/layer-name-formatter.js.map +7 -0
- package/dist/utils/markdown-anchor.js +7 -0
- package/dist/utils/markdown-anchor.js.map +7 -0
- package/dist/utils/markdown-link.js +12 -0
- package/dist/utils/markdown-link.js.map +7 -0
- package/dist/utils/markdown-table.js +17 -0
- package/dist/utils/markdown-table.js.map +7 -0
- package/dist/utils/mermaid-utils.js +11 -0
- package/dist/utils/mermaid-utils.js.map +7 -0
- package/dist/utils/project-paths.js.map +2 -2
- package/dist/utils/source-reference.js +52 -0
- package/dist/utils/source-reference.js.map +7 -0
- package/dist/utils/spec-installer.js +40 -53
- package/dist/utils/spec-installer.js.map +2 -2
- package/dist/utils/spec-version.js +5 -1
- package/dist/utils/spec-version.js.map +2 -2
- package/dist/utils/string-utils.js +12 -0
- package/dist/utils/string-utils.js.map +7 -0
- package/dist/utils/table-formatting.js +19 -0
- package/dist/utils/table-formatting.js.map +7 -0
- package/dist/validators/index.js +4 -0
- package/dist/validators/index.js.map +2 -2
- package/dist/validators/naming-validator.js +20 -23
- package/dist/validators/naming-validator.js.map +2 -2
- package/dist/validators/reference-validator.js +23 -38
- package/dist/validators/reference-validator.js.map +2 -2
- package/dist/validators/relationship-schema-validator.js +243 -0
- package/dist/validators/relationship-schema-validator.js.map +7 -0
- package/dist/validators/schema-validator.js +168 -68
- package/dist/validators/schema-validator.js.map +2 -2
- package/dist/validators/semantic-validator.js +36 -60
- package/dist/validators/semantic-validator.js.map +2 -2
- package/dist/validators/types.js.map +2 -2
- package/dist/validators/validation-formatter.js +159 -0
- package/dist/validators/validation-formatter.js.map +7 -0
- package/dist/validators/validator.js +24 -38
- package/dist/validators/validator.js.map +2 -2
- package/dist/viewer/README.md +139 -0
- package/dist/viewer/assets/main-CY0Xufuj.css +1 -0
- package/dist/viewer/assets/main-DtgErnwF.js +81 -0
- package/dist/viewer/assets/vendor-CxKvDp2x.js +17 -0
- package/dist/viewer/favicon.svg +11 -0
- package/dist/viewer/fonts/inter/Inter-Black.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Bold.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-ExtraBold.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Light.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Medium.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Regular.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-SemiBold.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2 +0 -0
- package/dist/viewer/index.html +15 -0
- package/dist/viewer/manifest.json +99 -0
- package/dist/viewer/version.json +1 -0
- package/package.json +37 -13
- package/PYTHON_CLI_PARITY.md +0 -265
- package/PYTHON_CLI_STRUCTURE_UPDATE.md +0 -246
- package/biome.json +0 -42
- package/bunfig.toml +0 -3
- package/dist/ai/claude-client.js +0 -71
- package/dist/ai/claude-client.js.map +0 -7
- package/dist/ai/context-provider.js +0 -129
- package/dist/ai/context-provider.js.map +0 -7
- package/dist/ai/tools.js +0 -231
- package/dist/ai/tools.js.map +0 -7
- package/dist/commands/migrate.js +0 -36
- package/dist/commands/migrate.js.map +0 -7
- package/dist/commands/project.js +0 -74
- package/dist/commands/project.js.map +0 -7
- package/dist/core/active-changeset.js +0 -52
- package/dist/core/active-changeset.js.map +0 -7
- package/dist/core/projection-engine.js +0 -288
- package/dist/core/projection-engine.js.map +0 -7
- package/dist/schemas/bundled/01-motivation-layer.schema.json +0 -942
- package/dist/schemas/bundled/02-business-layer.schema.json +0 -1293
- package/dist/schemas/bundled/03-security-layer.schema.json +0 -2177
- package/dist/schemas/bundled/04-application-layer.schema.json +0 -1328
- package/dist/schemas/bundled/05-technology-layer.schema.json +0 -1465
- package/dist/schemas/bundled/06-api-layer.schema.json +0 -1743
- package/dist/schemas/bundled/07-data-model-layer.schema.json +0 -1253
- package/dist/schemas/bundled/08-datastore-layer.schema.json +0 -892
- package/dist/schemas/bundled/09-ux-layer.schema.json +0 -1506
- package/dist/schemas/bundled/10-navigation-layer.schema.json +0 -843
- package/dist/schemas/bundled/11-apm-observability-layer.schema.json +0 -1430
- package/dist/schemas/bundled/12-testing-layer.schema.json +0 -1091
- package/dist/schemas/bundled/common/layer-extensions.schema.json +0 -266
- package/dist/schemas/bundled/common/predicates.schema.json +0 -493
- package/dist/schemas/bundled/common/relationships.schema.json +0 -791
- package/dist/schemas/bundled/common/source-references.schema.json +0 -71
- package/dist/schemas/bundled/link-registry.json +0 -1839
- package/dist/schemas/bundled/link-registry.schema.json +0 -339
- package/dist/schemas/bundled/relationship-catalog.json +0 -1302
- package/dist/schemas/bundled/relationship-type.schema.json +0 -221
- package/dist/utils/model-path.js +0 -22
- package/dist/utils/model-path.js.map +0 -7
- package/docs/TEST-INSTRUMENTATION.md +0 -405
- package/docs/telemetry.md +0 -427
- package/test-debug.js +0 -33
- package/test-special.mjs +0 -46
- package/test_runner.ts +0 -7
|
@@ -0,0 +1,933 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: LAYER_06_API
|
|
3
|
+
description: Expert knowledge for API Layer modeling in Documentation Robotics
|
|
4
|
+
triggers:
|
|
5
|
+
[
|
|
6
|
+
"OpenAPI",
|
|
7
|
+
"REST API",
|
|
8
|
+
"endpoint",
|
|
9
|
+
"operation",
|
|
10
|
+
"swagger",
|
|
11
|
+
"API specification",
|
|
12
|
+
"HTTP method",
|
|
13
|
+
"request",
|
|
14
|
+
"response"
|
|
15
|
+
]
|
|
16
|
+
version: 0.8.3
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# API Layer Skill
|
|
20
|
+
|
|
21
|
+
**Layer Number:** 06
|
|
22
|
+
**Specification:** Metadata Model Spec v0.8.3
|
|
23
|
+
**Purpose:** Defines REST API contracts using OpenAPI 3.0, specifying endpoints, operations, request/response schemas, and security requirements.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Layer Overview
|
|
28
|
+
|
|
29
|
+
The API Layer captures **API contracts**:
|
|
30
|
+
|
|
31
|
+
- **OPERATIONS** - HTTP methods on paths (GET, POST, PUT, DELETE, PATCH)
|
|
32
|
+
- **SCHEMAS** - Request/response data structures
|
|
33
|
+
- **SECURITY** - Authentication and authorization schemes
|
|
34
|
+
- **DOCUMENTATION** - API metadata, descriptions, examples
|
|
35
|
+
- **INTEGRATION** - Links to business services, application services, data models
|
|
36
|
+
|
|
37
|
+
This layer uses **OpenAPI 3.0.3** (de facto industry standard) with custom extensions for cross-layer traceability.
|
|
38
|
+
|
|
39
|
+
**Central Entity:** The **Operation** (HTTP method on a path) is the core modeling unit.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Entity Types
|
|
44
|
+
|
|
45
|
+
> **CLI Introspection:** Run `dr schema types api` for the authoritative, always-current list of node types.
|
|
46
|
+
> Run `dr schema node <type-id>` for full attribute details on any type.
|
|
47
|
+
|
|
48
|
+
### Core OpenAPI Entities (13 entities)
|
|
49
|
+
|
|
50
|
+
| Entity Type | Description |
|
|
51
|
+
| ------------------- | ------------------------------------------------------------------------------------------- |
|
|
52
|
+
| **OpenAPIDocument** | Root of an OpenAPI specification file (version 3.0.3) |
|
|
53
|
+
| **Info** | Metadata about the API (title, description, version, contact, license) |
|
|
54
|
+
| **Server** | Server where the API is available (with URL and variables) |
|
|
55
|
+
| **Paths** | Available API endpoints and operations |
|
|
56
|
+
| **PathItem** | Operations available on a path |
|
|
57
|
+
| **Operation** | Single API operation (HTTP method on a path) - **CENTRAL ENTITY** |
|
|
58
|
+
| **Parameter** | Parameter for an operation (locations: query, header, path, cookie) |
|
|
59
|
+
| **RequestBody** | Request payload for an operation |
|
|
60
|
+
| **Responses** | Possible responses from an operation |
|
|
61
|
+
| **Response** | Single response definition with status code |
|
|
62
|
+
| **MediaType** | Media type and schema for request/response body |
|
|
63
|
+
| **Components** | Reusable component definitions (schemas, responses, parameters, examples, security schemes) |
|
|
64
|
+
| **Schema** | Data type definition (JSON Schema subset) |
|
|
65
|
+
|
|
66
|
+
### Metadata Entities (11 entities)
|
|
67
|
+
|
|
68
|
+
| Entity Type | Description |
|
|
69
|
+
| ------------------------- | ---------------------------------------------------------------------- |
|
|
70
|
+
| **Tag** | Metadata label for grouping operations |
|
|
71
|
+
| **ExternalDocumentation** | Reference to external documentation |
|
|
72
|
+
| **Contact** | Contact information for API owner |
|
|
73
|
+
| **License** | Legal license for API |
|
|
74
|
+
| **ServerVariable** | Variable placeholder in server URL templates |
|
|
75
|
+
| **Header** | HTTP header parameters for requests/responses |
|
|
76
|
+
| **Link** | Relationship between API responses and subsequent operations (HATEOAS) |
|
|
77
|
+
| **Callback** | Webhook or callback URL pattern |
|
|
78
|
+
| **Example** | Sample values for documentation and testing |
|
|
79
|
+
| **Encoding** | Serialization details for multipart content |
|
|
80
|
+
| **SecurityScheme** | Security mechanism (types: apiKey, http, oauth2, openIdConnect) |
|
|
81
|
+
|
|
82
|
+
### Supporting Entities (3 entities)
|
|
83
|
+
|
|
84
|
+
| Entity Type | Description |
|
|
85
|
+
| -------------- | ------------------------------------------------------------------------------------------- |
|
|
86
|
+
| **OAuthFlows** | Configuration for OAuth 2.0 flows |
|
|
87
|
+
| **OAuthFlow** | Single OAuth 2.0 flow definition (authorizationCode, implicit, password, clientCredentials) |
|
|
88
|
+
| **RateLimit** | Rate limiting policy for an operation (requests per window, key strategy, action on breach) |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Type Decision Tree
|
|
93
|
+
|
|
94
|
+
For each construct encountered, ask "what is this?" and assign the first matching type.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Root OpenAPI specification file/object? → api.openapidocument
|
|
98
|
+
API-level metadata (title, description, version)? → api.info
|
|
99
|
+
Contact information for the API owner? → api.contact
|
|
100
|
+
Legal license declaration? → api.license
|
|
101
|
+
Server/host where the API is available (URL)? → api.server
|
|
102
|
+
Variable placeholder in a server URL template (e.g., {version})? → api.servervariable
|
|
103
|
+
Container of all URL paths (the `paths:` block)? → api.paths
|
|
104
|
+
A specific URL path with its available HTTP methods? → api.pathitem
|
|
105
|
+
A single HTTP method on a path (GET, POST, PUT, DELETE, PATCH)? → api.operation
|
|
106
|
+
A parameter — query, path, header, or cookie? → api.parameter
|
|
107
|
+
↳ NOTE: request bodies are NOT parameters → use api.requestbody
|
|
108
|
+
Request payload/body for an operation? → api.requestbody
|
|
109
|
+
Container of all possible responses for an operation? → api.responses
|
|
110
|
+
↳ NOTE: not a single response — use api.response for each status code
|
|
111
|
+
A single response for a specific HTTP status code? → api.response
|
|
112
|
+
Media type + schema pair (e.g., application/json with schema)? → api.mediatype
|
|
113
|
+
Data structure / schema definition (JSON Schema subset)? → api.schema
|
|
114
|
+
HTTP header for a request or response? → api.header
|
|
115
|
+
Grouping label used to organize operations? → api.tag
|
|
116
|
+
Reference to external documentation (URL)? → api.externaldocumentation
|
|
117
|
+
Container for reusable definitions (schemas, responses, params)? → api.components
|
|
118
|
+
Security mechanism definition (apiKey, http, oauth2)? → api.securityscheme
|
|
119
|
+
Container of all OAuth 2.0 flow types for a security scheme? → api.oauthflows
|
|
120
|
+
↳ NOTE: the individual flows inside are NOT api.oauthflows
|
|
121
|
+
A single OAuth 2.0 flow (authorizationCode, implicit, etc.)? → api.oauthflow
|
|
122
|
+
HATEOAS link from a response to a subsequent operation? → api.link
|
|
123
|
+
Webhook / callback URL pattern triggered by an operation? → api.callback
|
|
124
|
+
Sample value for documentation or testing? → api.example
|
|
125
|
+
Serialization details for multipart form content? → api.encoding
|
|
126
|
+
Rate limiting policy (requests per window, key strategy)? → api.ratelimit
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Common Misclassifications
|
|
132
|
+
|
|
133
|
+
| Misclassification | Correct Classification | Why |
|
|
134
|
+
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
135
|
+
| Using `api.response.*` for the set of all responses | `api.responses.*` is the container; `api.response.*` is a single status code response | `responses` is the plural container; `response` is one entry within it |
|
|
136
|
+
| Using `api.oauthflows.*` for a single flow | `api.oauthflow.*` — each flow variant (authorizationCode, implicit, etc.) is its own node | `oauthflows` is the multi-flow container; `oauthflow` is one flow definition |
|
|
137
|
+
| Modeling schemas inline as `api.mediatype.*` | Schemas are `api.schema.*`; `mediatype` just pairs a content type with a schema reference | MediaType is the content-type envelope; Schema is the data structure inside it |
|
|
138
|
+
| Using `api.parameter.*` for the request body | Request bodies are `api.requestbody.*`; parameters are query/path/header/cookie values only | The OpenAPI spec distinguishes body from parameters explicitly |
|
|
139
|
+
| Using `api.schema.*` for an entire API endpoint | Endpoints are `api.pathitem.*` + `api.operation.*`; schemas are data type definitions only | Schema ≠ endpoint |
|
|
140
|
+
| Putting rate limit config as a property on `api.operation.*` | `api.ratelimit.*` is a dedicated node type for rate limiting policies | Model rate limits as first-class nodes so they can be referenced and reasoned about independently |
|
|
141
|
+
| Using `api.components.*` to represent every reusable object | `api.components.*` is the container; individual reusables (schemas, parameters, etc.) are their own typed nodes composed under it | Components is a structural container, not a substitute for specific types |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Intra-Layer Relationships
|
|
146
|
+
|
|
147
|
+
### Composition Relationships (Part cannot exist without whole)
|
|
148
|
+
|
|
149
|
+
| Source | Predicate | Target | Example |
|
|
150
|
+
| --------------- | --------- | -------------- | --------------------------------- |
|
|
151
|
+
| OpenAPIDocument | composes | Info | Document has metadata |
|
|
152
|
+
| OpenAPIDocument | composes | Paths | Document defines endpoints |
|
|
153
|
+
| OpenAPIDocument | composes | Components | Document has reusable components |
|
|
154
|
+
| Paths | composes | PathItem | Paths contain path items |
|
|
155
|
+
| PathItem | composes | Operation | Path has HTTP methods |
|
|
156
|
+
| PathItem | composes | Parameter | Path-level parameters |
|
|
157
|
+
| Operation | composes | Parameter | Operation-specific parameters |
|
|
158
|
+
| Operation | composes | RequestBody | Request payload definition |
|
|
159
|
+
| Operation | composes | Responses | Response definitions |
|
|
160
|
+
| Responses | composes | Response | Individual status responses |
|
|
161
|
+
| RequestBody | composes | MediaType | Request content types |
|
|
162
|
+
| Response | composes | MediaType | Response content types |
|
|
163
|
+
| Response | composes | Header | Response headers |
|
|
164
|
+
| Response | composes | Link | HATEOAS links |
|
|
165
|
+
| MediaType | composes | Schema | Data structure |
|
|
166
|
+
| MediaType | composes | Example | Sample data |
|
|
167
|
+
| MediaType | composes | Encoding | Serialization details |
|
|
168
|
+
| Components | composes | Schema | Reusable schemas |
|
|
169
|
+
| Components | composes | Response | Reusable responses |
|
|
170
|
+
| Components | composes | Parameter | Reusable parameters |
|
|
171
|
+
| Components | composes | Example | Reusable examples |
|
|
172
|
+
| Components | composes | RequestBody | Reusable request bodies |
|
|
173
|
+
| Components | composes | Header | Reusable headers |
|
|
174
|
+
| Components | composes | SecurityScheme | Security definitions |
|
|
175
|
+
| Components | composes | Link | Reusable links |
|
|
176
|
+
| Components | composes | Callback | Reusable callbacks |
|
|
177
|
+
| Info | composes | Contact | API owner contact |
|
|
178
|
+
| Info | composes | License | API license |
|
|
179
|
+
| SecurityScheme | composes | OAuthFlows | OAuth2 configuration |
|
|
180
|
+
| OAuthFlows | composes | OAuthFlow | Individual OAuth2 flow definition |
|
|
181
|
+
|
|
182
|
+
### Aggregation Relationships (Part can exist independently)
|
|
183
|
+
|
|
184
|
+
| Source | Predicate | Target | Example |
|
|
185
|
+
| --------------- | ---------- | ------------------- | ------------------------ |
|
|
186
|
+
| OpenAPIDocument | aggregates | Server | API deployment servers |
|
|
187
|
+
| OpenAPIDocument | aggregates | Tag | Operation tags |
|
|
188
|
+
| OpenAPIDocument | aggregates | SecurityRequirement | Global security |
|
|
189
|
+
| Server | aggregates | ServerVariable | URL template variables |
|
|
190
|
+
| PathItem | aggregates | Parameter | Shared parameters |
|
|
191
|
+
| Operation | aggregates | Callback | Webhooks |
|
|
192
|
+
| Operation | aggregates | SecurityRequirement | Operation-level security |
|
|
193
|
+
|
|
194
|
+
### Reference Relationships
|
|
195
|
+
|
|
196
|
+
| Source | Predicate | Target | Example |
|
|
197
|
+
| --------------- | ---------- | --------------------- | -------------------------------------- |
|
|
198
|
+
| Schema | references | Schema | Schema $ref to another schema |
|
|
199
|
+
| Parameter | references | Schema | Parameter uses schema |
|
|
200
|
+
| Header | references | Schema | Header uses schema |
|
|
201
|
+
| Link | references | Operation | Link points to operation (operationId) |
|
|
202
|
+
| Callback | references | PathItem | Callback references path definition |
|
|
203
|
+
| Operation | references | Tag | Operation tagged for grouping |
|
|
204
|
+
| Tag | references | ExternalDocumentation | Tag links to external docs |
|
|
205
|
+
| OpenAPIDocument | references | ExternalDocumentation | Document links to external docs |
|
|
206
|
+
| Encoding | references | Header | Encoding uses headers |
|
|
207
|
+
|
|
208
|
+
### Specialization Relationships
|
|
209
|
+
|
|
210
|
+
| Source | Predicate | Target | Example |
|
|
211
|
+
| ------ | ----------- | ------ | ---------------------------------------- |
|
|
212
|
+
| Schema | specializes | Schema | Schema inheritance (allOf, oneOf, anyOf) |
|
|
213
|
+
|
|
214
|
+
### Behavioral Relationships
|
|
215
|
+
|
|
216
|
+
| Source | Predicate | Target | Example |
|
|
217
|
+
| -------------- | --------- | --------- | ---------------------------------- |
|
|
218
|
+
| Operation | triggers | Callback | Operation invokes webhook |
|
|
219
|
+
| SecurityScheme | serves | Operation | Security scheme protects operation |
|
|
220
|
+
|
|
221
|
+
### Association Relationships
|
|
222
|
+
|
|
223
|
+
| Source | Predicate | Target | Example |
|
|
224
|
+
| ------- | --------------- | --------------- | -------------------- |
|
|
225
|
+
| Contact | associated-with | OpenAPIDocument | Contact info for API |
|
|
226
|
+
| License | associated-with | OpenAPIDocument | Legal license |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Cross-Layer References
|
|
231
|
+
|
|
232
|
+
### Outgoing References (API → Other Layers)
|
|
233
|
+
|
|
234
|
+
OpenAPI specification includes **custom extensions** (x-\* properties) for cross-layer traceability:
|
|
235
|
+
|
|
236
|
+
Cross-layer links to Business and Application layers use `dr relationship add`:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
dr relationship add api.<type>.<name> business.<type>.<name> --predicate realizes
|
|
240
|
+
dr relationship add api.<type>.<name> application.<type>.<name> --predicate realizes
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Use `dr catalog types` to list all valid predicates.
|
|
244
|
+
|
|
245
|
+
OpenAPI **x-\* properties** (set via `--properties`) are used for same-element metadata:
|
|
246
|
+
|
|
247
|
+
| Target Layer | Extension Property | Example |
|
|
248
|
+
| ------------------------ | ------------------------------- | --------------------------------------------------- |
|
|
249
|
+
| **Layer 1 (Motivation)** | `x-supports-goals` | Operation supports business goals |
|
|
250
|
+
| **Layer 1 (Motivation)** | `x-fulfills-requirements` | Operation fulfills functional requirements |
|
|
251
|
+
| **Layer 1 (Motivation)** | `x-governed-by-principles` | Operation follows architectural principles |
|
|
252
|
+
| **Layer 1 (Motivation)** | `x-constrained-by` | Operation subject to constraints (GDPR, HIPAA, SOX) |
|
|
253
|
+
| **Layer 7 (Data Model)** | `schema.$ref` | Schema references JSON Schema definition |
|
|
254
|
+
| **Layer 3 (Security)** | `x-security-resource` | Operation protected by SecureResource |
|
|
255
|
+
| **Layer 3 (Security)** | `x-required-permissions` | Operation requires specific permissions |
|
|
256
|
+
| **Layer 3 (Security)** | `x-rate-limit` | Rate limiting configuration |
|
|
257
|
+
| **Layer 11 (APM)** | `x-apm-business-metrics` | Operation tracked by business metrics |
|
|
258
|
+
| **Layer 11 (APM)** | `x-apm-sla-target-latency` | Expected response time (e.g., "100ms") |
|
|
259
|
+
| **Layer 11 (APM)** | `x-apm-sla-target-availability` | Expected availability (e.g., "99.9%") |
|
|
260
|
+
| **Layer 11 (APM)** | `x-apm-trace` | Distributed tracing enabled |
|
|
261
|
+
| **Layer 11 (APM)** | `x-apm-criticality` | Business criticality (critical, high, medium, low) |
|
|
262
|
+
|
|
263
|
+
### Incoming References (Lower Layers → API)
|
|
264
|
+
|
|
265
|
+
Lower layers reference API layer to show implementation and data structure.
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Codebase Detection Patterns
|
|
270
|
+
|
|
271
|
+
### Pattern 1: FastAPI Python
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
from fastapi import FastAPI, HTTPException
|
|
275
|
+
from pydantic import BaseModel
|
|
276
|
+
|
|
277
|
+
app = FastAPI(
|
|
278
|
+
title="User Management API", # OpenAPIDocument: Info.title
|
|
279
|
+
description="API for managing user accounts", # Info.description
|
|
280
|
+
version="1.0.0" # Info.version
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
class UserCreateRequest(BaseModel): # Schema (RequestBody)
|
|
284
|
+
username: str
|
|
285
|
+
email: str
|
|
286
|
+
full_name: str
|
|
287
|
+
|
|
288
|
+
class UserResponse(BaseModel): # Schema (Response)
|
|
289
|
+
user_id: str
|
|
290
|
+
username: str
|
|
291
|
+
email: str
|
|
292
|
+
created_at: datetime
|
|
293
|
+
|
|
294
|
+
@app.post(
|
|
295
|
+
"/api/users", # PathItem + Operation (POST)
|
|
296
|
+
response_model=UserResponse, # Response schema
|
|
297
|
+
status_code=201, # Response status
|
|
298
|
+
tags=["Users"], # Tag
|
|
299
|
+
summary="Create a new user", # Operation.summary
|
|
300
|
+
description="Creates a new user account with the provided details" # Operation.description
|
|
301
|
+
)
|
|
302
|
+
async def create_user(user: UserCreateRequest) -> UserResponse: # RequestBody + Response
|
|
303
|
+
"""
|
|
304
|
+
x-apm-sla-target-latency: 200ms
|
|
305
|
+
x-required-permissions: users.write
|
|
306
|
+
"""
|
|
307
|
+
pass
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Maps to:**
|
|
311
|
+
|
|
312
|
+
- OpenAPIDocument: "User Management API"
|
|
313
|
+
- PathItem: "/api/users"
|
|
314
|
+
- Operation: "POST /api/users"
|
|
315
|
+
- RequestBody: MediaType (application/json) with Schema (UserCreateRequest)
|
|
316
|
+
- Response: 201 with Schema (UserResponse)
|
|
317
|
+
- Tag: "Users"
|
|
318
|
+
|
|
319
|
+
### Pattern 2: Express.js TypeScript
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import express from "express";
|
|
323
|
+
import { body, param, query, validationResult } from "express-validator";
|
|
324
|
+
|
|
325
|
+
const router = express.Router();
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @openapi
|
|
329
|
+
* /api/orders/{orderId}:
|
|
330
|
+
* get:
|
|
331
|
+
* summary: Get order by ID
|
|
332
|
+
* description: Retrieves a single order by its unique identifier
|
|
333
|
+
* tags:
|
|
334
|
+
* - Orders
|
|
335
|
+
* parameters:
|
|
336
|
+
* - name: orderId
|
|
337
|
+
* in: path
|
|
338
|
+
* required: true
|
|
339
|
+
* schema:
|
|
340
|
+
* type: string
|
|
341
|
+
* format: uuid
|
|
342
|
+
* responses:
|
|
343
|
+
* 200:
|
|
344
|
+
* description: Order found
|
|
345
|
+
* content:
|
|
346
|
+
* application/json:
|
|
347
|
+
* schema:
|
|
348
|
+
* $ref: '#/components/schemas/Order'
|
|
349
|
+
* 404:
|
|
350
|
+
* description: Order not found
|
|
351
|
+
* x-apm-sla-target-latency: 100ms
|
|
352
|
+
* x-apm-criticality: high
|
|
353
|
+
*/
|
|
354
|
+
router.get(
|
|
355
|
+
"/api/orders/:orderId",
|
|
356
|
+
param("orderId").isUUID(),
|
|
357
|
+
async (req, res) => {
|
|
358
|
+
// Implementation
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Maps to:**
|
|
364
|
+
|
|
365
|
+
- PathItem: "/api/orders/{orderId}"
|
|
366
|
+
- Operation: "GET /api/orders/{orderId}"
|
|
367
|
+
- Parameter: "orderId" (in: path, type: string, format: uuid)
|
|
368
|
+
- Response: 200 with schema reference
|
|
369
|
+
- Response: 404 error response
|
|
370
|
+
- Custom extensions: x-apm-sla-target-latency, x-apm-criticality
|
|
371
|
+
|
|
372
|
+
### Pattern 3: Spring Boot Java
|
|
373
|
+
|
|
374
|
+
```java
|
|
375
|
+
@RestController
|
|
376
|
+
@RequestMapping("/api/products")
|
|
377
|
+
@Tag(name = "Products", description = "Product management operations")
|
|
378
|
+
public class ProductController {
|
|
379
|
+
|
|
380
|
+
@Operation(
|
|
381
|
+
summary = "List products",
|
|
382
|
+
description = "Returns a paginated list of products",
|
|
383
|
+
extensions = {
|
|
384
|
+
@Extension(name = "x-apm-sla-target-latency", properties = @ExtensionProperty(name = "latency", value = "150ms")),
|
|
385
|
+
@Extension(name = "x-required-permissions", properties = @ExtensionProperty(name = "permissions", value = "products.read"))
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
@ApiResponses({
|
|
389
|
+
@ApiResponse(
|
|
390
|
+
responseCode = "200",
|
|
391
|
+
description = "Products retrieved successfully",
|
|
392
|
+
content = @Content(
|
|
393
|
+
mediaType = "application/json",
|
|
394
|
+
schema = @Schema(implementation = ProductListResponse.class)
|
|
395
|
+
)
|
|
396
|
+
)
|
|
397
|
+
})
|
|
398
|
+
@GetMapping
|
|
399
|
+
public ResponseEntity<ProductListResponse> listProducts(
|
|
400
|
+
@Parameter(description = "Page number", example = "1") @RequestParam(defaultValue = "1") int page,
|
|
401
|
+
@Parameter(description = "Page size", example = "20") @RequestParam(defaultValue = "20") int size
|
|
402
|
+
) {
|
|
403
|
+
// Implementation
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Maps to:**
|
|
409
|
+
|
|
410
|
+
- PathItem: "/api/products"
|
|
411
|
+
- Operation: "GET /api/products"
|
|
412
|
+
- Parameters: "page" (query), "size" (query)
|
|
413
|
+
- Response: 200 with ProductListResponse schema
|
|
414
|
+
- Tag: "Products"
|
|
415
|
+
- Custom extensions
|
|
416
|
+
|
|
417
|
+
### Pattern 4: OpenAPI YAML Definition
|
|
418
|
+
|
|
419
|
+
```yaml
|
|
420
|
+
openapi: 3.0.3
|
|
421
|
+
info:
|
|
422
|
+
title: Payment Processing API
|
|
423
|
+
description: API for processing customer payments
|
|
424
|
+
version: 2.1.0
|
|
425
|
+
contact:
|
|
426
|
+
name: API Support
|
|
427
|
+
email: api-support@example.com
|
|
428
|
+
license:
|
|
429
|
+
name: MIT
|
|
430
|
+
url: https://opensource.org/licenses/MIT
|
|
431
|
+
x-governed-by-principles:
|
|
432
|
+
- motivation/principle/api-first-design
|
|
433
|
+
- motivation/principle/security-by-design
|
|
434
|
+
|
|
435
|
+
servers:
|
|
436
|
+
- url: https://api.example.com/v2
|
|
437
|
+
description: Production server
|
|
438
|
+
- url: https://staging-api.example.com/v2
|
|
439
|
+
description: Staging server
|
|
440
|
+
|
|
441
|
+
paths:
|
|
442
|
+
/payments:
|
|
443
|
+
post:
|
|
444
|
+
summary: Process payment
|
|
445
|
+
description: Processes a payment transaction
|
|
446
|
+
operationId: processPayment
|
|
447
|
+
tags:
|
|
448
|
+
- Payments
|
|
449
|
+
security:
|
|
450
|
+
- oauth2: [payments.write]
|
|
451
|
+
requestBody:
|
|
452
|
+
required: true
|
|
453
|
+
content:
|
|
454
|
+
application/json:
|
|
455
|
+
schema:
|
|
456
|
+
$ref: "#/components/schemas/PaymentRequest"
|
|
457
|
+
examples:
|
|
458
|
+
credit-card:
|
|
459
|
+
$ref: "#/components/examples/CreditCardPayment"
|
|
460
|
+
responses:
|
|
461
|
+
"201":
|
|
462
|
+
description: Payment processed successfully
|
|
463
|
+
content:
|
|
464
|
+
application/json:
|
|
465
|
+
schema:
|
|
466
|
+
$ref: "#/components/schemas/PaymentResponse"
|
|
467
|
+
"400":
|
|
468
|
+
$ref: "#/components/responses/BadRequest"
|
|
469
|
+
"401":
|
|
470
|
+
$ref: "#/components/responses/Unauthorized"
|
|
471
|
+
x-apm-sla-target-latency: 500ms
|
|
472
|
+
x-apm-sla-target-availability: 99.99%
|
|
473
|
+
x-apm-criticality: critical
|
|
474
|
+
x-required-permissions:
|
|
475
|
+
- payments.write
|
|
476
|
+
x-rate-limit:
|
|
477
|
+
requests: 100
|
|
478
|
+
window: 60s
|
|
479
|
+
|
|
480
|
+
components:
|
|
481
|
+
schemas:
|
|
482
|
+
PaymentRequest:
|
|
483
|
+
type: object
|
|
484
|
+
required:
|
|
485
|
+
- amount
|
|
486
|
+
- currency
|
|
487
|
+
- payment_method
|
|
488
|
+
properties:
|
|
489
|
+
amount:
|
|
490
|
+
type: number
|
|
491
|
+
format: double
|
|
492
|
+
minimum: 0.01
|
|
493
|
+
example: 99.99
|
|
494
|
+
currency:
|
|
495
|
+
type: string
|
|
496
|
+
enum: [USD, EUR, GBP]
|
|
497
|
+
example: USD
|
|
498
|
+
payment_method:
|
|
499
|
+
$ref: "#/components/schemas/PaymentMethod"
|
|
500
|
+
|
|
501
|
+
PaymentResponse:
|
|
502
|
+
type: object
|
|
503
|
+
properties:
|
|
504
|
+
transaction_id:
|
|
505
|
+
type: string
|
|
506
|
+
format: uuid
|
|
507
|
+
status:
|
|
508
|
+
type: string
|
|
509
|
+
enum: [pending, completed, failed]
|
|
510
|
+
timestamp:
|
|
511
|
+
type: string
|
|
512
|
+
format: date-time
|
|
513
|
+
|
|
514
|
+
securitySchemes:
|
|
515
|
+
oauth2:
|
|
516
|
+
type: oauth2
|
|
517
|
+
flows:
|
|
518
|
+
authorizationCode:
|
|
519
|
+
authorizationUrl: https://auth.example.com/oauth/authorize
|
|
520
|
+
tokenUrl: https://auth.example.com/oauth/token
|
|
521
|
+
scopes:
|
|
522
|
+
payments.read: Read payment information
|
|
523
|
+
payments.write: Process payments
|
|
524
|
+
|
|
525
|
+
responses:
|
|
526
|
+
BadRequest:
|
|
527
|
+
description: Invalid request
|
|
528
|
+
content:
|
|
529
|
+
application/json:
|
|
530
|
+
schema:
|
|
531
|
+
$ref: "#/components/schemas/Error"
|
|
532
|
+
|
|
533
|
+
examples:
|
|
534
|
+
CreditCardPayment:
|
|
535
|
+
value:
|
|
536
|
+
amount: 99.99
|
|
537
|
+
currency: USD
|
|
538
|
+
payment_method:
|
|
539
|
+
type: credit_card
|
|
540
|
+
card_number: "4111111111111111"
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
## Modeling Workflow
|
|
546
|
+
|
|
547
|
+
### Step 1: Create OpenAPI Document
|
|
548
|
+
|
|
549
|
+
```bash
|
|
550
|
+
# Create the API specification document
|
|
551
|
+
dr add api openapidocument "payment-api" \
|
|
552
|
+
--description "API for processing customer payments"
|
|
553
|
+
|
|
554
|
+
# Add API metadata
|
|
555
|
+
# NOTE: api.info requires a companion api.openapidocument to avoid orphan warnings.
|
|
556
|
+
# Always create api.openapidocument first, then link api.info to it via composes.
|
|
557
|
+
dr add api info "payment-api-info" \
|
|
558
|
+
--description "API metadata and contact information"
|
|
559
|
+
|
|
560
|
+
dr relationship add api.openapidocument.payment-api \
|
|
561
|
+
api.info.payment-api-info --predicate composes
|
|
562
|
+
|
|
563
|
+
# Link to motivation layer
|
|
564
|
+
dr relationship add api.openapidocument.payment-api \
|
|
565
|
+
motivation.principle.api-first-design --predicate governed-by
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### Step 2: Define Servers
|
|
569
|
+
|
|
570
|
+
```bash
|
|
571
|
+
# Production server
|
|
572
|
+
dr add api server "production-server" \
|
|
573
|
+
--description "Production API server"
|
|
574
|
+
|
|
575
|
+
# Staging server
|
|
576
|
+
dr add api server "staging-server" \
|
|
577
|
+
--description "Staging API server"
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### Step 3: Define Security Schemes
|
|
581
|
+
|
|
582
|
+
```bash
|
|
583
|
+
# OAuth2 security
|
|
584
|
+
dr add api securityscheme "oauth2-auth" \
|
|
585
|
+
--description "OAuth2 authorization code flow"
|
|
586
|
+
|
|
587
|
+
# API Key security
|
|
588
|
+
dr add api securityscheme "api-key-auth" \
|
|
589
|
+
--description "API key authentication"
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Step 4: Define Schemas (Data Models)
|
|
593
|
+
|
|
594
|
+
```bash
|
|
595
|
+
# Request schema
|
|
596
|
+
dr add api schema "payment-request" \
|
|
597
|
+
--description "Payment request payload"
|
|
598
|
+
|
|
599
|
+
# Response schema
|
|
600
|
+
dr add api schema "payment-response" \
|
|
601
|
+
--description "Payment processing response"
|
|
602
|
+
|
|
603
|
+
# Link to data model layer
|
|
604
|
+
dr relationship add api.schema.payment-request \
|
|
605
|
+
data-model.schema.payment-request --predicate references
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### Step 5: Define Operations (Core Entities)
|
|
609
|
+
|
|
610
|
+
```bash
|
|
611
|
+
# POST operation
|
|
612
|
+
dr add api operation "process-payment" \
|
|
613
|
+
--description "Processes a payment transaction"
|
|
614
|
+
|
|
615
|
+
# Add APM and security extensions
|
|
616
|
+
dr add api operation "process-payment" \
|
|
617
|
+
|
|
618
|
+
# Link to business layer via relationship
|
|
619
|
+
dr relationship add api.operation.process-payment business.service.payment-processing --predicate realizes
|
|
620
|
+
|
|
621
|
+
# GET operation
|
|
622
|
+
dr add api operation "get-payment" \
|
|
623
|
+
--description "Retrieves payment details by ID"
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Step 6: Define Parameters
|
|
627
|
+
|
|
628
|
+
```bash
|
|
629
|
+
# Path parameter
|
|
630
|
+
dr add api parameter "payment-id-param" \
|
|
631
|
+
--description "Payment transaction ID"
|
|
632
|
+
|
|
633
|
+
# Query parameter
|
|
634
|
+
dr add api parameter "status-filter" \
|
|
635
|
+
--description "Filter payments by status"
|
|
636
|
+
|
|
637
|
+
# Link parameter to operation
|
|
638
|
+
dr relationship add api.operation.get-payment \
|
|
639
|
+
api.parameter.payment-id-param --predicate has-parameter
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Step 7: Define Request/Response Bodies
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
# Request body
|
|
646
|
+
dr add api requestbody "payment-request-body" \
|
|
647
|
+
--description "Payment request payload"
|
|
648
|
+
|
|
649
|
+
# Link request body to schema
|
|
650
|
+
dr relationship add api.requestbody.payment-request-body \
|
|
651
|
+
api.schema.payment-request --predicate uses-schema
|
|
652
|
+
|
|
653
|
+
# Response
|
|
654
|
+
dr add api response "payment-success-response" \
|
|
655
|
+
--description "Successful payment response"
|
|
656
|
+
|
|
657
|
+
# Link response to schema
|
|
658
|
+
dr relationship add api.response.payment-success-response \
|
|
659
|
+
api.schema.payment-response --predicate uses-schema
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Step 8: Define Tags for Organization
|
|
663
|
+
|
|
664
|
+
```bash
|
|
665
|
+
# Add tags
|
|
666
|
+
dr add api tag "payments" \
|
|
667
|
+
--description "Payment processing operations"
|
|
668
|
+
|
|
669
|
+
dr add api tag "refunds" \
|
|
670
|
+
--description "Refund operations"
|
|
671
|
+
|
|
672
|
+
# Tag operations
|
|
673
|
+
dr relationship add api.operation.process-payment \
|
|
674
|
+
api.tag.payments --predicate tagged-with
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
### Step 9: Cross-Layer Integration
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
# Link to business layer
|
|
681
|
+
dr relationship add api.operation.process-payment \
|
|
682
|
+
business.service.payment-processing --predicate realizes
|
|
683
|
+
|
|
684
|
+
# Link to application layer
|
|
685
|
+
dr relationship add api.openapidocument.payment-api \
|
|
686
|
+
application.service.payment-api --predicate realizes
|
|
687
|
+
|
|
688
|
+
# Link to security layer
|
|
689
|
+
dr relationship add api.operation.process-payment \
|
|
690
|
+
security.secure-resource.payment-api --predicate protected-by
|
|
691
|
+
|
|
692
|
+
# Link to motivation layer
|
|
693
|
+
dr relationship add api.operation.process-payment \
|
|
694
|
+
motivation.goal.reduce-checkout-time --predicate supports
|
|
695
|
+
|
|
696
|
+
# Link to APM layer
|
|
697
|
+
dr relationship add api.operation.process-payment \
|
|
698
|
+
apm.metric.payment-processing-latency --predicate tracked-by
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
### Step 10: Validate and Export
|
|
702
|
+
|
|
703
|
+
```bash
|
|
704
|
+
# Validate API layer
|
|
705
|
+
dr validate --layers api
|
|
706
|
+
|
|
707
|
+
# Export to OpenAPI YAML
|
|
708
|
+
dr export openapi --output payment-api.yaml
|
|
709
|
+
|
|
710
|
+
# Validate exported OpenAPI with external tools
|
|
711
|
+
spectral lint payment-api.yaml
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
---
|
|
715
|
+
|
|
716
|
+
## Operation-Level SLA Patterns
|
|
717
|
+
|
|
718
|
+
Different operations have different SLA targets:
|
|
719
|
+
|
|
720
|
+
```yaml
|
|
721
|
+
# Search operation: fast response
|
|
722
|
+
x-apm-sla-target-latency: "50ms"
|
|
723
|
+
x-apm-sla-target-availability: "99.9%"
|
|
724
|
+
x-apm-criticality: "high"
|
|
725
|
+
|
|
726
|
+
# Write operation: moderate latency
|
|
727
|
+
x-apm-sla-target-latency: "200ms"
|
|
728
|
+
x-apm-sla-target-availability: "99.95%"
|
|
729
|
+
x-apm-criticality: "critical"
|
|
730
|
+
|
|
731
|
+
# Batch operation: longer latency acceptable
|
|
732
|
+
x-apm-sla-target-latency: "10s"
|
|
733
|
+
x-apm-sla-target-availability: "99.5%"
|
|
734
|
+
x-apm-criticality: "medium"
|
|
735
|
+
|
|
736
|
+
# Reporting: can be slower
|
|
737
|
+
x-apm-sla-target-latency: "5s"
|
|
738
|
+
x-apm-sla-target-availability: "99%"
|
|
739
|
+
x-apm-criticality: "low"
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
---
|
|
743
|
+
|
|
744
|
+
## Best Practices
|
|
745
|
+
|
|
746
|
+
1. **Operation is the Central Entity** - Model operations, not just paths
|
|
747
|
+
2. **Use OpenAPI 3.0.3** - Latest stable version with broad tooling support
|
|
748
|
+
3. **Tag Operations** - Organize operations by domain or resource
|
|
749
|
+
4. **Define Reusable Components** - Schemas, responses, parameters in Components section
|
|
750
|
+
5. **Document Examples** - Include request/response examples for testing and documentation
|
|
751
|
+
6. **Security at Operation Level** - Different operations can have different security requirements
|
|
752
|
+
7. **Link to Business Services** - Use `dr relationship add` to link API operations to business services for traceability
|
|
753
|
+
8. **Define SLA Targets** - Use x-apm-sla-target-\* for monitoring
|
|
754
|
+
9. **Version APIs Properly** - Use semantic versioning (major.minor.patch)
|
|
755
|
+
10. **Generate from Code** - Use FastAPI, NestJS decorators, or Springdoc to auto-generate OpenAPI specs
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
|
|
759
|
+
## OpenAPI Tooling Ecosystem
|
|
760
|
+
|
|
761
|
+
### Generation Tools
|
|
762
|
+
|
|
763
|
+
- **FastAPI** (Python) - Auto-generates OpenAPI from Python decorators
|
|
764
|
+
- **NestJS** (TypeScript) - Swagger module for OpenAPI generation
|
|
765
|
+
- **Springdoc** (Java) - OpenAPI 3 for Spring Boot applications
|
|
766
|
+
- **Express + swagger-jsdoc** (Node.js) - Generate from JSDoc comments
|
|
767
|
+
|
|
768
|
+
### Validation Tools
|
|
769
|
+
|
|
770
|
+
- **Spectral** - OpenAPI linter and validator
|
|
771
|
+
- **openapi-validator** - IBM's OpenAPI validator
|
|
772
|
+
- **swagger-cli** - Validate and bundle OpenAPI specs
|
|
773
|
+
|
|
774
|
+
### Documentation Tools
|
|
775
|
+
|
|
776
|
+
- **Swagger UI** - Interactive API documentation
|
|
777
|
+
- **Redoc** - Clean, customizable API documentation
|
|
778
|
+
- **Postman** - Import OpenAPI for API testing
|
|
779
|
+
|
|
780
|
+
### Code Generation Tools
|
|
781
|
+
|
|
782
|
+
- **OpenAPI Generator** - Generate client SDKs and server stubs
|
|
783
|
+
- **swagger-codegen** - Legacy code generation tool
|
|
784
|
+
- **oapi-codegen** (Go) - Generate Go server/client from OpenAPI
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
|
|
788
|
+
## Validation Tips
|
|
789
|
+
|
|
790
|
+
| Issue | Cause | Fix |
|
|
791
|
+
| -------------------- | -------------------------------------- | ----------------------------------------------------------------------------- |
|
|
792
|
+
| Missing Operations | Paths defined but no operations | Add HTTP methods (GET, POST, etc.) |
|
|
793
|
+
| Unlinked Schemas | Schemas not referenced by operations | Link schemas to request/response bodies |
|
|
794
|
+
| Missing Security | Operations lack security requirements | Add securitySchemes and apply to operations |
|
|
795
|
+
| No Cross-Layer Links | API not linked to business/application | Run `dr relationship add <api-element> <target-element> --predicate realizes` |
|
|
796
|
+
| Missing SLA Targets | Operations lack performance targets | Add x-apm-sla-target-\* extensions |
|
|
797
|
+
| Untagged Operations | Operations not organized by tags | Add tags for grouping |
|
|
798
|
+
| No Examples | Schemas lack examples | Add example values for documentation |
|
|
799
|
+
| Invalid OpenAPI | Spec doesn't validate | Use Spectral or openapi-validator |
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
## Quick Reference
|
|
804
|
+
|
|
805
|
+
**Add Commands:**
|
|
806
|
+
|
|
807
|
+
```bash
|
|
808
|
+
dr add api openapidocument <name>
|
|
809
|
+
dr add api operation <name>
|
|
810
|
+
dr add api schema <name>
|
|
811
|
+
dr add api parameter <name>
|
|
812
|
+
dr add api securityscheme <name>
|
|
813
|
+
dr add api tag <name>
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
**Relationship Commands:**
|
|
817
|
+
|
|
818
|
+
```bash
|
|
819
|
+
dr relationship add <operation> <schema> --predicate uses-schema
|
|
820
|
+
dr relationship add <operation> <parameter> --predicate has-parameter
|
|
821
|
+
dr relationship add <operation> <tag> --predicate tagged-with
|
|
822
|
+
dr relationship add <schema> <schema> --predicate references
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
**Cross-Layer Commands:**
|
|
826
|
+
|
|
827
|
+
```bash
|
|
828
|
+
dr relationship add <api-operation> <business-service> --predicate realizes
|
|
829
|
+
dr relationship add <api-openapidocument> <application-service> --predicate realizes
|
|
830
|
+
dr relationship add <api-schema> <data-model-schema> --predicate references
|
|
831
|
+
dr relationship add <api-operation> <security-resource> --predicate protected-by
|
|
832
|
+
dr relationship add <api-operation> <motivation-goal> --predicate supports
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
**Export Commands:**
|
|
836
|
+
|
|
837
|
+
```bash
|
|
838
|
+
dr export openapi --output api-spec.yaml
|
|
839
|
+
dr export openapi --layers api --output api-spec.json
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
**Validation Commands:**
|
|
843
|
+
|
|
844
|
+
```bash
|
|
845
|
+
dr validate --layers api
|
|
846
|
+
spectral lint api-spec.yaml
|
|
847
|
+
swagger-cli validate api-spec.yaml
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
---
|
|
851
|
+
|
|
852
|
+
## Custom Extension Reference
|
|
853
|
+
|
|
854
|
+
Documentation Robotics defines custom OpenAPI extensions for cross-layer traceability:
|
|
855
|
+
|
|
856
|
+
```yaml
|
|
857
|
+
# Motivation Layer Links
|
|
858
|
+
x-supports-goals: [motivation/goal/id1, motivation/goal/id2]
|
|
859
|
+
x-fulfills-requirements: [motivation/requirement/id1]
|
|
860
|
+
x-governed-by-principles: [motivation/principle/id1]
|
|
861
|
+
x-constrained-by: [motivation/constraint/id1]
|
|
862
|
+
|
|
863
|
+
# Business and Application Layer Links — use dr relationship add (not x-* properties)
|
|
864
|
+
# dr relationship add api.<type>.<name> business.<type>.<name> --predicate realizes
|
|
865
|
+
# dr relationship add api.<type>.<name> application.<type>.<name> --predicate realizes
|
|
866
|
+
|
|
867
|
+
# Security Layer Links
|
|
868
|
+
x-security-resource: security/secure-resource/id
|
|
869
|
+
x-required-permissions: [users.read, users.write]
|
|
870
|
+
x-rate-limit:
|
|
871
|
+
requests: 100
|
|
872
|
+
window: 60s
|
|
873
|
+
|
|
874
|
+
# APM Layer Links
|
|
875
|
+
x-apm-business-metrics: [apm/metric/id1]
|
|
876
|
+
x-apm-sla-target-latency: "100ms"
|
|
877
|
+
x-apm-sla-target-availability: "99.9%"
|
|
878
|
+
x-apm-trace: true
|
|
879
|
+
x-apm-criticality: "high" # critical, high, medium, low
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
These extensions enable full traceability from API operations to business goals, requirements, security controls, and monitoring metrics.
|
|
883
|
+
|
|
884
|
+
---
|
|
885
|
+
|
|
886
|
+
## Coverage Completeness Checklist
|
|
887
|
+
|
|
888
|
+
Before declaring API layer extraction complete, verify each type was considered:
|
|
889
|
+
|
|
890
|
+
- [ ] **api.openapidocument** — Root OpenAPI specification document
|
|
891
|
+
- [ ] **api.info** — API metadata (title, version, description)
|
|
892
|
+
- [ ] **api.contact** — Contact information for the API owner
|
|
893
|
+
- [ ] **api.license** — Legal license for the API
|
|
894
|
+
- [ ] **api.server** — Server URLs where the API is available
|
|
895
|
+
- [ ] **api.servervariable** — Variable placeholders in server URL templates
|
|
896
|
+
- [ ] **api.paths** — Container of all API endpoint paths
|
|
897
|
+
- [ ] **api.pathitem** — Operations available on a specific URL path
|
|
898
|
+
- [ ] **api.operation** — Individual HTTP operations (GET, POST, PUT, DELETE, PATCH) — CENTRAL ENTITY
|
|
899
|
+
- [ ] **api.parameter** — Query, path, header, or cookie parameters
|
|
900
|
+
- [ ] **api.requestbody** — Request payload for an operation
|
|
901
|
+
- [ ] **api.responses** — Container of all possible responses for an operation
|
|
902
|
+
- [ ] **api.response** — Single response definition for a specific HTTP status code
|
|
903
|
+
- [ ] **api.mediatype** — Media type + schema pair for request/response bodies
|
|
904
|
+
- [ ] **api.schema** — Data type definitions (JSON Schema subset)
|
|
905
|
+
- [ ] **api.header** — HTTP header parameters
|
|
906
|
+
- [ ] **api.tag** — Grouping labels for organizing operations
|
|
907
|
+
- [ ] **api.externaldocumentation** — References to external documentation
|
|
908
|
+
- [ ] **api.components** — Container for reusable API component definitions
|
|
909
|
+
- [ ] **api.securityscheme** — Security mechanism definitions (apiKey, http, oauth2, openIdConnect)
|
|
910
|
+
- [ ] **api.oauthflows** — OAuth 2.0 flows configuration container
|
|
911
|
+
- [ ] **api.oauthflow** — Single OAuth 2.0 flow (authorizationCode, implicit, password, clientCredentials)
|
|
912
|
+
- [ ] **api.link** — HATEOAS links from responses to subsequent operations
|
|
913
|
+
- [ ] **api.callback** — Webhook / callback URL patterns
|
|
914
|
+
- [ ] **api.example** — Sample values for documentation and testing
|
|
915
|
+
- [ ] **api.encoding** — Serialization details for multipart content
|
|
916
|
+
- [ ] **api.ratelimit** — Rate limiting policies (requests per window, key strategy)
|
|
917
|
+
|
|
918
|
+
If any type has ZERO elements, explicitly decide:
|
|
919
|
+
"This type doesn't apply to this codebase" with reasoning.
|
|
920
|
+
|
|
921
|
+
---
|
|
922
|
+
|
|
923
|
+
## Summary
|
|
924
|
+
|
|
925
|
+
The API Layer is the **contract layer** - it defines HOW external consumers interact with your system. Every operation should:
|
|
926
|
+
|
|
927
|
+
1. Be linked to a business service (traceability)
|
|
928
|
+
2. Have clear request/response schemas
|
|
929
|
+
3. Define security requirements
|
|
930
|
+
4. Specify SLA targets for monitoring
|
|
931
|
+
5. Include examples for documentation and testing
|
|
932
|
+
|
|
933
|
+
Use OpenAPI 3.0.3 as the foundation, leverage auto-generation tools from your framework, and extend with custom properties for full cross-layer integration.
|