@documentation-robotics/cli 0.1.0 → 0.1.7
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 +208 -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 +162 -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 +42 -16
- 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,855 @@
|
|
|
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.1
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# API Layer Skill
|
|
20
|
+
|
|
21
|
+
**Layer Number:** 06
|
|
22
|
+
**Specification:** Metadata Model Spec v0.8.1
|
|
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
|
+
| **Condition** | Logical expression for policy evaluation |
|
|
88
|
+
| **RetentionPolicy** | Data retention policies |
|
|
89
|
+
| **ValidationRule** | Data validation constraints |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Intra-Layer Relationships
|
|
94
|
+
|
|
95
|
+
### Composition Relationships (Part cannot exist without whole)
|
|
96
|
+
|
|
97
|
+
| Source | Predicate | Target | Example |
|
|
98
|
+
| --------------- | --------- | -------------- | -------------------------------- |
|
|
99
|
+
| OpenAPIDocument | composes | Info | Document has metadata |
|
|
100
|
+
| OpenAPIDocument | composes | Paths | Document defines endpoints |
|
|
101
|
+
| OpenAPIDocument | composes | Components | Document has reusable components |
|
|
102
|
+
| Paths | composes | PathItem | Paths contain path items |
|
|
103
|
+
| PathItem | composes | Operation | Path has HTTP methods |
|
|
104
|
+
| PathItem | composes | Parameter | Path-level parameters |
|
|
105
|
+
| Operation | composes | Parameter | Operation-specific parameters |
|
|
106
|
+
| Operation | composes | RequestBody | Request payload definition |
|
|
107
|
+
| Operation | composes | Responses | Response definitions |
|
|
108
|
+
| Responses | composes | Response | Individual status responses |
|
|
109
|
+
| RequestBody | composes | MediaType | Request content types |
|
|
110
|
+
| Response | composes | MediaType | Response content types |
|
|
111
|
+
| Response | composes | Header | Response headers |
|
|
112
|
+
| Response | composes | Link | HATEOAS links |
|
|
113
|
+
| MediaType | composes | Schema | Data structure |
|
|
114
|
+
| MediaType | composes | Example | Sample data |
|
|
115
|
+
| MediaType | composes | Encoding | Serialization details |
|
|
116
|
+
| Components | composes | Schema | Reusable schemas |
|
|
117
|
+
| Components | composes | Response | Reusable responses |
|
|
118
|
+
| Components | composes | Parameter | Reusable parameters |
|
|
119
|
+
| Components | composes | Example | Reusable examples |
|
|
120
|
+
| Components | composes | RequestBody | Reusable request bodies |
|
|
121
|
+
| Components | composes | Header | Reusable headers |
|
|
122
|
+
| Components | composes | SecurityScheme | Security definitions |
|
|
123
|
+
| Components | composes | Link | Reusable links |
|
|
124
|
+
| Components | composes | Callback | Reusable callbacks |
|
|
125
|
+
| Info | composes | Contact | API owner contact |
|
|
126
|
+
| Info | composes | License | API license |
|
|
127
|
+
| SecurityScheme | composes | OAuthFlows | OAuth2 configuration |
|
|
128
|
+
|
|
129
|
+
### Aggregation Relationships (Part can exist independently)
|
|
130
|
+
|
|
131
|
+
| Source | Predicate | Target | Example |
|
|
132
|
+
| --------------- | ---------- | ------------------- | ------------------------ |
|
|
133
|
+
| OpenAPIDocument | aggregates | Server | API deployment servers |
|
|
134
|
+
| OpenAPIDocument | aggregates | Tag | Operation tags |
|
|
135
|
+
| OpenAPIDocument | aggregates | SecurityRequirement | Global security |
|
|
136
|
+
| Server | aggregates | ServerVariable | URL template variables |
|
|
137
|
+
| PathItem | aggregates | Parameter | Shared parameters |
|
|
138
|
+
| Operation | aggregates | Callback | Webhooks |
|
|
139
|
+
| Operation | aggregates | SecurityRequirement | Operation-level security |
|
|
140
|
+
|
|
141
|
+
### Reference Relationships
|
|
142
|
+
|
|
143
|
+
| Source | Predicate | Target | Example |
|
|
144
|
+
| --------------- | ---------- | --------------------- | -------------------------------------- |
|
|
145
|
+
| Schema | references | Schema | Schema $ref to another schema |
|
|
146
|
+
| Parameter | references | Schema | Parameter uses schema |
|
|
147
|
+
| Header | references | Schema | Header uses schema |
|
|
148
|
+
| Link | references | Operation | Link points to operation (operationId) |
|
|
149
|
+
| Callback | references | PathItem | Callback references path definition |
|
|
150
|
+
| Operation | references | Tag | Operation tagged for grouping |
|
|
151
|
+
| Tag | references | ExternalDocumentation | Tag links to external docs |
|
|
152
|
+
| OpenAPIDocument | references | ExternalDocumentation | Document links to external docs |
|
|
153
|
+
| Encoding | references | Header | Encoding uses headers |
|
|
154
|
+
|
|
155
|
+
### Specialization Relationships
|
|
156
|
+
|
|
157
|
+
| Source | Predicate | Target | Example |
|
|
158
|
+
| ------ | ----------- | ------ | ---------------------------------------- |
|
|
159
|
+
| Schema | specializes | Schema | Schema inheritance (allOf, oneOf, anyOf) |
|
|
160
|
+
|
|
161
|
+
### Behavioral Relationships
|
|
162
|
+
|
|
163
|
+
| Source | Predicate | Target | Example |
|
|
164
|
+
| -------------- | --------- | --------- | ---------------------------------- |
|
|
165
|
+
| Operation | triggers | Callback | Operation invokes webhook |
|
|
166
|
+
| SecurityScheme | serves | Operation | Security scheme protects operation |
|
|
167
|
+
|
|
168
|
+
### Association Relationships
|
|
169
|
+
|
|
170
|
+
| Source | Predicate | Target | Example |
|
|
171
|
+
| ------- | --------------- | --------------- | -------------------- |
|
|
172
|
+
| Contact | associated-with | OpenAPIDocument | Contact info for API |
|
|
173
|
+
| License | associated-with | OpenAPIDocument | Legal license |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Cross-Layer References
|
|
178
|
+
|
|
179
|
+
### Outgoing References (API → Other Layers)
|
|
180
|
+
|
|
181
|
+
OpenAPI specification includes **custom extensions** (x-\* properties) for cross-layer traceability:
|
|
182
|
+
|
|
183
|
+
Cross-layer links to Business and Application layers use `dr relationship add`:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
dr relationship add api.<type>.<name> business.<type>.<name> --predicate realizes
|
|
187
|
+
dr relationship add api.<type>.<name> application.<type>.<name> --predicate realizes
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Use `dr catalog types` to list all valid predicates.
|
|
191
|
+
|
|
192
|
+
OpenAPI **x-\* properties** (set via `--properties`) are used for same-element metadata:
|
|
193
|
+
|
|
194
|
+
| Target Layer | Extension Property | Example |
|
|
195
|
+
| ------------------------ | ------------------------------- | --------------------------------------------------- |
|
|
196
|
+
| **Layer 1 (Motivation)** | `x-supports-goals` | Operation supports business goals |
|
|
197
|
+
| **Layer 1 (Motivation)** | `x-fulfills-requirements` | Operation fulfills functional requirements |
|
|
198
|
+
| **Layer 1 (Motivation)** | `x-governed-by-principles` | Operation follows architectural principles |
|
|
199
|
+
| **Layer 1 (Motivation)** | `x-constrained-by` | Operation subject to constraints (GDPR, HIPAA, SOX) |
|
|
200
|
+
| **Layer 7 (Data Model)** | `schema.$ref` | Schema references JSON Schema definition |
|
|
201
|
+
| **Layer 3 (Security)** | `x-security-resource` | Operation protected by SecureResource |
|
|
202
|
+
| **Layer 3 (Security)** | `x-required-permissions` | Operation requires specific permissions |
|
|
203
|
+
| **Layer 3 (Security)** | `x-rate-limit` | Rate limiting configuration |
|
|
204
|
+
| **Layer 11 (APM)** | `x-apm-business-metrics` | Operation tracked by business metrics |
|
|
205
|
+
| **Layer 11 (APM)** | `x-apm-sla-target-latency` | Expected response time (e.g., "100ms") |
|
|
206
|
+
| **Layer 11 (APM)** | `x-apm-sla-target-availability` | Expected availability (e.g., "99.9%") |
|
|
207
|
+
| **Layer 11 (APM)** | `x-apm-trace` | Distributed tracing enabled |
|
|
208
|
+
| **Layer 11 (APM)** | `x-apm-criticality` | Business criticality (critical, high, medium, low) |
|
|
209
|
+
|
|
210
|
+
### Incoming References (Lower Layers → API)
|
|
211
|
+
|
|
212
|
+
Lower layers reference API layer to show implementation and data structure.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Codebase Detection Patterns
|
|
217
|
+
|
|
218
|
+
### Pattern 1: FastAPI Python
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from fastapi import FastAPI, HTTPException
|
|
222
|
+
from pydantic import BaseModel
|
|
223
|
+
|
|
224
|
+
app = FastAPI(
|
|
225
|
+
title="User Management API", # OpenAPIDocument: Info.title
|
|
226
|
+
description="API for managing user accounts", # Info.description
|
|
227
|
+
version="1.0.0" # Info.version
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
class UserCreateRequest(BaseModel): # Schema (RequestBody)
|
|
231
|
+
username: str
|
|
232
|
+
email: str
|
|
233
|
+
full_name: str
|
|
234
|
+
|
|
235
|
+
class UserResponse(BaseModel): # Schema (Response)
|
|
236
|
+
user_id: str
|
|
237
|
+
username: str
|
|
238
|
+
email: str
|
|
239
|
+
created_at: datetime
|
|
240
|
+
|
|
241
|
+
@app.post(
|
|
242
|
+
"/api/users", # PathItem + Operation (POST)
|
|
243
|
+
response_model=UserResponse, # Response schema
|
|
244
|
+
status_code=201, # Response status
|
|
245
|
+
tags=["Users"], # Tag
|
|
246
|
+
summary="Create a new user", # Operation.summary
|
|
247
|
+
description="Creates a new user account with the provided details" # Operation.description
|
|
248
|
+
)
|
|
249
|
+
async def create_user(user: UserCreateRequest) -> UserResponse: # RequestBody + Response
|
|
250
|
+
"""
|
|
251
|
+
x-apm-sla-target-latency: 200ms
|
|
252
|
+
x-required-permissions: users.write
|
|
253
|
+
"""
|
|
254
|
+
pass
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Maps to:**
|
|
258
|
+
|
|
259
|
+
- OpenAPIDocument: "User Management API"
|
|
260
|
+
- PathItem: "/api/users"
|
|
261
|
+
- Operation: "POST /api/users"
|
|
262
|
+
- RequestBody: MediaType (application/json) with Schema (UserCreateRequest)
|
|
263
|
+
- Response: 201 with Schema (UserResponse)
|
|
264
|
+
- Tag: "Users"
|
|
265
|
+
|
|
266
|
+
### Pattern 2: Express.js TypeScript
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import express from "express";
|
|
270
|
+
import { body, param, query, validationResult } from "express-validator";
|
|
271
|
+
|
|
272
|
+
const router = express.Router();
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @openapi
|
|
276
|
+
* /api/orders/{orderId}:
|
|
277
|
+
* get:
|
|
278
|
+
* summary: Get order by ID
|
|
279
|
+
* description: Retrieves a single order by its unique identifier
|
|
280
|
+
* tags:
|
|
281
|
+
* - Orders
|
|
282
|
+
* parameters:
|
|
283
|
+
* - name: orderId
|
|
284
|
+
* in: path
|
|
285
|
+
* required: true
|
|
286
|
+
* schema:
|
|
287
|
+
* type: string
|
|
288
|
+
* format: uuid
|
|
289
|
+
* responses:
|
|
290
|
+
* 200:
|
|
291
|
+
* description: Order found
|
|
292
|
+
* content:
|
|
293
|
+
* application/json:
|
|
294
|
+
* schema:
|
|
295
|
+
* $ref: '#/components/schemas/Order'
|
|
296
|
+
* 404:
|
|
297
|
+
* description: Order not found
|
|
298
|
+
* x-apm-sla-target-latency: 100ms
|
|
299
|
+
* x-apm-criticality: high
|
|
300
|
+
*/
|
|
301
|
+
router.get(
|
|
302
|
+
"/api/orders/:orderId",
|
|
303
|
+
param("orderId").isUUID(),
|
|
304
|
+
async (req, res) => {
|
|
305
|
+
// Implementation
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Maps to:**
|
|
311
|
+
|
|
312
|
+
- PathItem: "/api/orders/{orderId}"
|
|
313
|
+
- Operation: "GET /api/orders/{orderId}"
|
|
314
|
+
- Parameter: "orderId" (in: path, type: string, format: uuid)
|
|
315
|
+
- Response: 200 with schema reference
|
|
316
|
+
- Response: 404 error response
|
|
317
|
+
- Custom extensions: x-apm-sla-target-latency, x-apm-criticality
|
|
318
|
+
|
|
319
|
+
### Pattern 3: Spring Boot Java
|
|
320
|
+
|
|
321
|
+
```java
|
|
322
|
+
@RestController
|
|
323
|
+
@RequestMapping("/api/products")
|
|
324
|
+
@Tag(name = "Products", description = "Product management operations")
|
|
325
|
+
public class ProductController {
|
|
326
|
+
|
|
327
|
+
@Operation(
|
|
328
|
+
summary = "List products",
|
|
329
|
+
description = "Returns a paginated list of products",
|
|
330
|
+
extensions = {
|
|
331
|
+
@Extension(name = "x-apm-sla-target-latency", properties = @ExtensionProperty(name = "latency", value = "150ms")),
|
|
332
|
+
@Extension(name = "x-required-permissions", properties = @ExtensionProperty(name = "permissions", value = "products.read"))
|
|
333
|
+
}
|
|
334
|
+
)
|
|
335
|
+
@ApiResponses({
|
|
336
|
+
@ApiResponse(
|
|
337
|
+
responseCode = "200",
|
|
338
|
+
description = "Products retrieved successfully",
|
|
339
|
+
content = @Content(
|
|
340
|
+
mediaType = "application/json",
|
|
341
|
+
schema = @Schema(implementation = ProductListResponse.class)
|
|
342
|
+
)
|
|
343
|
+
)
|
|
344
|
+
})
|
|
345
|
+
@GetMapping
|
|
346
|
+
public ResponseEntity<ProductListResponse> listProducts(
|
|
347
|
+
@Parameter(description = "Page number", example = "1") @RequestParam(defaultValue = "1") int page,
|
|
348
|
+
@Parameter(description = "Page size", example = "20") @RequestParam(defaultValue = "20") int size
|
|
349
|
+
) {
|
|
350
|
+
// Implementation
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Maps to:**
|
|
356
|
+
|
|
357
|
+
- PathItem: "/api/products"
|
|
358
|
+
- Operation: "GET /api/products"
|
|
359
|
+
- Parameters: "page" (query), "size" (query)
|
|
360
|
+
- Response: 200 with ProductListResponse schema
|
|
361
|
+
- Tag: "Products"
|
|
362
|
+
- Custom extensions
|
|
363
|
+
|
|
364
|
+
### Pattern 4: OpenAPI YAML Definition
|
|
365
|
+
|
|
366
|
+
```yaml
|
|
367
|
+
openapi: 3.0.3
|
|
368
|
+
info:
|
|
369
|
+
title: Payment Processing API
|
|
370
|
+
description: API for processing customer payments
|
|
371
|
+
version: 2.1.0
|
|
372
|
+
contact:
|
|
373
|
+
name: API Support
|
|
374
|
+
email: api-support@example.com
|
|
375
|
+
license:
|
|
376
|
+
name: MIT
|
|
377
|
+
url: https://opensource.org/licenses/MIT
|
|
378
|
+
x-governed-by-principles:
|
|
379
|
+
- motivation/principle/api-first-design
|
|
380
|
+
- motivation/principle/security-by-design
|
|
381
|
+
|
|
382
|
+
servers:
|
|
383
|
+
- url: https://api.example.com/v2
|
|
384
|
+
description: Production server
|
|
385
|
+
- url: https://staging-api.example.com/v2
|
|
386
|
+
description: Staging server
|
|
387
|
+
|
|
388
|
+
paths:
|
|
389
|
+
/payments:
|
|
390
|
+
post:
|
|
391
|
+
summary: Process payment
|
|
392
|
+
description: Processes a payment transaction
|
|
393
|
+
operationId: processPayment
|
|
394
|
+
tags:
|
|
395
|
+
- Payments
|
|
396
|
+
security:
|
|
397
|
+
- oauth2: [payments.write]
|
|
398
|
+
requestBody:
|
|
399
|
+
required: true
|
|
400
|
+
content:
|
|
401
|
+
application/json:
|
|
402
|
+
schema:
|
|
403
|
+
$ref: "#/components/schemas/PaymentRequest"
|
|
404
|
+
examples:
|
|
405
|
+
credit-card:
|
|
406
|
+
$ref: "#/components/examples/CreditCardPayment"
|
|
407
|
+
responses:
|
|
408
|
+
"201":
|
|
409
|
+
description: Payment processed successfully
|
|
410
|
+
content:
|
|
411
|
+
application/json:
|
|
412
|
+
schema:
|
|
413
|
+
$ref: "#/components/schemas/PaymentResponse"
|
|
414
|
+
"400":
|
|
415
|
+
$ref: "#/components/responses/BadRequest"
|
|
416
|
+
"401":
|
|
417
|
+
$ref: "#/components/responses/Unauthorized"
|
|
418
|
+
x-apm-sla-target-latency: 500ms
|
|
419
|
+
x-apm-sla-target-availability: 99.99%
|
|
420
|
+
x-apm-criticality: critical
|
|
421
|
+
x-required-permissions:
|
|
422
|
+
- payments.write
|
|
423
|
+
x-rate-limit:
|
|
424
|
+
requests: 100
|
|
425
|
+
window: 60s
|
|
426
|
+
|
|
427
|
+
components:
|
|
428
|
+
schemas:
|
|
429
|
+
PaymentRequest:
|
|
430
|
+
type: object
|
|
431
|
+
required:
|
|
432
|
+
- amount
|
|
433
|
+
- currency
|
|
434
|
+
- payment_method
|
|
435
|
+
properties:
|
|
436
|
+
amount:
|
|
437
|
+
type: number
|
|
438
|
+
format: double
|
|
439
|
+
minimum: 0.01
|
|
440
|
+
example: 99.99
|
|
441
|
+
currency:
|
|
442
|
+
type: string
|
|
443
|
+
enum: [USD, EUR, GBP]
|
|
444
|
+
example: USD
|
|
445
|
+
payment_method:
|
|
446
|
+
$ref: "#/components/schemas/PaymentMethod"
|
|
447
|
+
|
|
448
|
+
PaymentResponse:
|
|
449
|
+
type: object
|
|
450
|
+
properties:
|
|
451
|
+
transaction_id:
|
|
452
|
+
type: string
|
|
453
|
+
format: uuid
|
|
454
|
+
status:
|
|
455
|
+
type: string
|
|
456
|
+
enum: [pending, completed, failed]
|
|
457
|
+
timestamp:
|
|
458
|
+
type: string
|
|
459
|
+
format: date-time
|
|
460
|
+
|
|
461
|
+
securitySchemes:
|
|
462
|
+
oauth2:
|
|
463
|
+
type: oauth2
|
|
464
|
+
flows:
|
|
465
|
+
authorizationCode:
|
|
466
|
+
authorizationUrl: https://auth.example.com/oauth/authorize
|
|
467
|
+
tokenUrl: https://auth.example.com/oauth/token
|
|
468
|
+
scopes:
|
|
469
|
+
payments.read: Read payment information
|
|
470
|
+
payments.write: Process payments
|
|
471
|
+
|
|
472
|
+
responses:
|
|
473
|
+
BadRequest:
|
|
474
|
+
description: Invalid request
|
|
475
|
+
content:
|
|
476
|
+
application/json:
|
|
477
|
+
schema:
|
|
478
|
+
$ref: "#/components/schemas/Error"
|
|
479
|
+
|
|
480
|
+
examples:
|
|
481
|
+
CreditCardPayment:
|
|
482
|
+
value:
|
|
483
|
+
amount: 99.99
|
|
484
|
+
currency: USD
|
|
485
|
+
payment_method:
|
|
486
|
+
type: credit_card
|
|
487
|
+
card_number: "4111111111111111"
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## Modeling Workflow
|
|
493
|
+
|
|
494
|
+
### Step 1: Create OpenAPI Document
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
# Create the API specification document
|
|
498
|
+
dr add api document "payment-api" \
|
|
499
|
+
--properties version=3.0.3,title="Payment Processing API",api-version=2.1.0 \
|
|
500
|
+
--description "API for processing customer payments"
|
|
501
|
+
|
|
502
|
+
# Add API metadata
|
|
503
|
+
dr add api info "payment-api-info" \
|
|
504
|
+
--properties title="Payment Processing API",version=2.1.0,contact-email=api@example.com \
|
|
505
|
+
--description "API metadata and contact information"
|
|
506
|
+
|
|
507
|
+
# Link to motivation layer
|
|
508
|
+
dr relationship add "api/document/payment-api" \
|
|
509
|
+
governed-by "motivation/principle/api-first-design"
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### Step 2: Define Servers
|
|
513
|
+
|
|
514
|
+
```bash
|
|
515
|
+
# Production server
|
|
516
|
+
dr add api server "production-server" \
|
|
517
|
+
--properties url=https://api.example.com/v2,description="Production server" \
|
|
518
|
+
--description "Production API server"
|
|
519
|
+
|
|
520
|
+
# Staging server
|
|
521
|
+
dr add api server "staging-server" \
|
|
522
|
+
--properties url=https://staging-api.example.com/v2,description="Staging server" \
|
|
523
|
+
--description "Staging API server"
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### Step 3: Define Security Schemes
|
|
527
|
+
|
|
528
|
+
```bash
|
|
529
|
+
# OAuth2 security
|
|
530
|
+
dr add api security-scheme "oauth2-auth" \
|
|
531
|
+
--properties type=oauth2,flow=authorizationCode,authorization-url=https://auth.example.com/oauth/authorize,token-url=https://auth.example.com/oauth/token \
|
|
532
|
+
--description "OAuth2 authorization code flow"
|
|
533
|
+
|
|
534
|
+
# API Key security
|
|
535
|
+
dr add api security-scheme "api-key-auth" \
|
|
536
|
+
--properties type=apiKey,in=header,name=X-API-Key \
|
|
537
|
+
--description "API key authentication"
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### Step 4: Define Schemas (Data Models)
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
# Request schema
|
|
544
|
+
dr add api schema "payment-request" \
|
|
545
|
+
--properties type=object,required=amount:currency:payment_method \
|
|
546
|
+
--description "Payment request payload"
|
|
547
|
+
|
|
548
|
+
# Response schema
|
|
549
|
+
dr add api schema "payment-response" \
|
|
550
|
+
--properties type=object \
|
|
551
|
+
--description "Payment processing response"
|
|
552
|
+
|
|
553
|
+
# Link to data model layer
|
|
554
|
+
dr relationship add "api/schema/payment-request" \
|
|
555
|
+
references "data-model/schema/payment-request"
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### Step 5: Define Operations (Core Entities)
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
# POST operation
|
|
562
|
+
dr add api operation "process-payment" \
|
|
563
|
+
--properties path=/payments,method=POST,operation-id=processPayment \
|
|
564
|
+
--description "Processes a payment transaction"
|
|
565
|
+
|
|
566
|
+
# Add APM and security extensions
|
|
567
|
+
dr add api operation "process-payment" \
|
|
568
|
+
--properties x-apm-sla-target-latency=500ms,x-apm-sla-target-availability=99.99%,x-apm-criticality=critical,x-required-permissions=payments.write
|
|
569
|
+
|
|
570
|
+
# Link to business layer via relationship
|
|
571
|
+
dr relationship add api.operation.process-payment business.service.payment-processing --predicate realizes
|
|
572
|
+
|
|
573
|
+
# GET operation
|
|
574
|
+
dr add api operation "get-payment" \
|
|
575
|
+
--properties path=/payments/{paymentId},method=GET,operation-id=getPayment \
|
|
576
|
+
--description "Retrieves payment details by ID"
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### Step 6: Define Parameters
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# Path parameter
|
|
583
|
+
dr add api parameter "payment-id-param" \
|
|
584
|
+
--properties name=paymentId,in=path,required=true,type=string,format=uuid \
|
|
585
|
+
--description "Payment transaction ID"
|
|
586
|
+
|
|
587
|
+
# Query parameter
|
|
588
|
+
dr add api parameter "status-filter" \
|
|
589
|
+
--properties name=status,in=query,required=false,type=string,enum=pending:completed:failed \
|
|
590
|
+
--description "Filter payments by status"
|
|
591
|
+
|
|
592
|
+
# Link parameter to operation
|
|
593
|
+
dr relationship add "api/operation/get-payment" \
|
|
594
|
+
has-parameter "api/parameter/payment-id-param"
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
### Step 7: Define Request/Response Bodies
|
|
598
|
+
|
|
599
|
+
```bash
|
|
600
|
+
# Request body
|
|
601
|
+
dr add api request-body "payment-request-body" \
|
|
602
|
+
--properties required=true,content-type=application/json \
|
|
603
|
+
--description "Payment request payload"
|
|
604
|
+
|
|
605
|
+
# Link request body to schema
|
|
606
|
+
dr relationship add "api/request-body/payment-request-body" \
|
|
607
|
+
uses-schema "api/schema/payment-request"
|
|
608
|
+
|
|
609
|
+
# Response
|
|
610
|
+
dr add api response "payment-success-response" \
|
|
611
|
+
--properties status-code=201,description="Payment processed successfully" \
|
|
612
|
+
--description "Successful payment response"
|
|
613
|
+
|
|
614
|
+
# Link response to schema
|
|
615
|
+
dr relationship add "api/response/payment-success-response" \
|
|
616
|
+
uses-schema "api/schema/payment-response"
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### Step 8: Define Tags for Organization
|
|
620
|
+
|
|
621
|
+
```bash
|
|
622
|
+
# Add tags
|
|
623
|
+
dr add api tag "payments" \
|
|
624
|
+
--properties name=Payments \
|
|
625
|
+
--description "Payment processing operations"
|
|
626
|
+
|
|
627
|
+
dr add api tag "refunds" \
|
|
628
|
+
--properties name=Refunds \
|
|
629
|
+
--description "Refund operations"
|
|
630
|
+
|
|
631
|
+
# Tag operations
|
|
632
|
+
dr relationship add "api/operation/process-payment" \
|
|
633
|
+
tagged-with "api/tag/payments"
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
### Step 9: Cross-Layer Integration
|
|
637
|
+
|
|
638
|
+
```bash
|
|
639
|
+
# Link to business layer
|
|
640
|
+
dr relationship add "api/operation/process-payment" \
|
|
641
|
+
realizes "business/service/payment-processing"
|
|
642
|
+
|
|
643
|
+
# Link to application layer
|
|
644
|
+
dr relationship add "api/document/payment-api" \
|
|
645
|
+
realizes "application/service/payment-api"
|
|
646
|
+
|
|
647
|
+
# Link to security layer
|
|
648
|
+
dr relationship add "api/operation/process-payment" \
|
|
649
|
+
protected-by "security/secure-resource/payment-api"
|
|
650
|
+
|
|
651
|
+
# Link to motivation layer
|
|
652
|
+
dr relationship add "api/operation/process-payment" \
|
|
653
|
+
supports "motivation/goal/reduce-checkout-time"
|
|
654
|
+
|
|
655
|
+
# Link to APM layer
|
|
656
|
+
dr relationship add "api/operation/process-payment" \
|
|
657
|
+
tracked-by "apm/metric/payment-processing-latency"
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
### Step 10: Validate and Export
|
|
661
|
+
|
|
662
|
+
```bash
|
|
663
|
+
# Validate API layer
|
|
664
|
+
dr validate --layer api
|
|
665
|
+
|
|
666
|
+
# Export to OpenAPI YAML
|
|
667
|
+
dr export openapi --output payment-api.yaml
|
|
668
|
+
|
|
669
|
+
# Validate exported OpenAPI with external tools
|
|
670
|
+
spectral lint payment-api.yaml
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
---
|
|
674
|
+
|
|
675
|
+
## Operation-Level SLA Patterns
|
|
676
|
+
|
|
677
|
+
Different operations have different SLA targets:
|
|
678
|
+
|
|
679
|
+
```yaml
|
|
680
|
+
# Search operation: fast response
|
|
681
|
+
x-apm-sla-target-latency: "50ms"
|
|
682
|
+
x-apm-sla-target-availability: "99.9%"
|
|
683
|
+
x-apm-criticality: "high"
|
|
684
|
+
|
|
685
|
+
# Write operation: moderate latency
|
|
686
|
+
x-apm-sla-target-latency: "200ms"
|
|
687
|
+
x-apm-sla-target-availability: "99.95%"
|
|
688
|
+
x-apm-criticality: "critical"
|
|
689
|
+
|
|
690
|
+
# Batch operation: longer latency acceptable
|
|
691
|
+
x-apm-sla-target-latency: "10s"
|
|
692
|
+
x-apm-sla-target-availability: "99.5%"
|
|
693
|
+
x-apm-criticality: "medium"
|
|
694
|
+
|
|
695
|
+
# Reporting: can be slower
|
|
696
|
+
x-apm-sla-target-latency: "5s"
|
|
697
|
+
x-apm-sla-target-availability: "99%"
|
|
698
|
+
x-apm-criticality: "low"
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
---
|
|
702
|
+
|
|
703
|
+
## Best Practices
|
|
704
|
+
|
|
705
|
+
1. **Operation is the Central Entity** - Model operations, not just paths
|
|
706
|
+
2. **Use OpenAPI 3.0.3** - Latest stable version with broad tooling support
|
|
707
|
+
3. **Tag Operations** - Organize operations by domain or resource
|
|
708
|
+
4. **Define Reusable Components** - Schemas, responses, parameters in Components section
|
|
709
|
+
5. **Document Examples** - Include request/response examples for testing and documentation
|
|
710
|
+
6. **Security at Operation Level** - Different operations can have different security requirements
|
|
711
|
+
7. **Link to Business Services** - Use `dr relationship add` to link API operations to business services for traceability
|
|
712
|
+
8. **Define SLA Targets** - Use x-apm-sla-target-\* for monitoring
|
|
713
|
+
9. **Version APIs Properly** - Use semantic versioning (major.minor.patch)
|
|
714
|
+
10. **Generate from Code** - Use FastAPI, NestJS decorators, or Springdoc to auto-generate OpenAPI specs
|
|
715
|
+
|
|
716
|
+
---
|
|
717
|
+
|
|
718
|
+
## OpenAPI Tooling Ecosystem
|
|
719
|
+
|
|
720
|
+
### Generation Tools
|
|
721
|
+
|
|
722
|
+
- **FastAPI** (Python) - Auto-generates OpenAPI from Python decorators
|
|
723
|
+
- **NestJS** (TypeScript) - Swagger module for OpenAPI generation
|
|
724
|
+
- **Springdoc** (Java) - OpenAPI 3 for Spring Boot applications
|
|
725
|
+
- **Express + swagger-jsdoc** (Node.js) - Generate from JSDoc comments
|
|
726
|
+
|
|
727
|
+
### Validation Tools
|
|
728
|
+
|
|
729
|
+
- **Spectral** - OpenAPI linter and validator
|
|
730
|
+
- **openapi-validator** - IBM's OpenAPI validator
|
|
731
|
+
- **swagger-cli** - Validate and bundle OpenAPI specs
|
|
732
|
+
|
|
733
|
+
### Documentation Tools
|
|
734
|
+
|
|
735
|
+
- **Swagger UI** - Interactive API documentation
|
|
736
|
+
- **Redoc** - Clean, customizable API documentation
|
|
737
|
+
- **Postman** - Import OpenAPI for API testing
|
|
738
|
+
|
|
739
|
+
### Code Generation Tools
|
|
740
|
+
|
|
741
|
+
- **OpenAPI Generator** - Generate client SDKs and server stubs
|
|
742
|
+
- **swagger-codegen** - Legacy code generation tool
|
|
743
|
+
- **oapi-codegen** (Go) - Generate Go server/client from OpenAPI
|
|
744
|
+
|
|
745
|
+
---
|
|
746
|
+
|
|
747
|
+
## Validation Tips
|
|
748
|
+
|
|
749
|
+
| Issue | Cause | Fix |
|
|
750
|
+
| -------------------- | -------------------------------------- | ----------------------------------------------------------------------------- |
|
|
751
|
+
| Missing Operations | Paths defined but no operations | Add HTTP methods (GET, POST, etc.) |
|
|
752
|
+
| Unlinked Schemas | Schemas not referenced by operations | Link schemas to request/response bodies |
|
|
753
|
+
| Missing Security | Operations lack security requirements | Add securitySchemes and apply to operations |
|
|
754
|
+
| No Cross-Layer Links | API not linked to business/application | Run `dr relationship add <api-element> <target-element> --predicate realizes` |
|
|
755
|
+
| Missing SLA Targets | Operations lack performance targets | Add x-apm-sla-target-\* extensions |
|
|
756
|
+
| Untagged Operations | Operations not organized by tags | Add tags for grouping |
|
|
757
|
+
| No Examples | Schemas lack examples | Add example values for documentation |
|
|
758
|
+
| Invalid OpenAPI | Spec doesn't validate | Use Spectral or openapi-validator |
|
|
759
|
+
|
|
760
|
+
---
|
|
761
|
+
|
|
762
|
+
## Quick Reference
|
|
763
|
+
|
|
764
|
+
**Add Commands:**
|
|
765
|
+
|
|
766
|
+
```bash
|
|
767
|
+
dr add api document <name> --properties version=3.0.3,title=<title>
|
|
768
|
+
dr add api operation <name> --properties path=<path>,method=<method>
|
|
769
|
+
dr add api schema <name> --properties type=<type>
|
|
770
|
+
dr add api parameter <name> --properties name=<name>,in=<location>
|
|
771
|
+
dr add api security-scheme <name> --properties type=<type>
|
|
772
|
+
dr add api tag <name> --properties name=<display-name>
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
**Relationship Commands:**
|
|
776
|
+
|
|
777
|
+
```bash
|
|
778
|
+
dr relationship add <operation> uses-schema <schema>
|
|
779
|
+
dr relationship add <operation> has-parameter <parameter>
|
|
780
|
+
dr relationship add <operation> tagged-with <tag>
|
|
781
|
+
dr relationship add <schema> references <schema>
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
**Cross-Layer Commands:**
|
|
785
|
+
|
|
786
|
+
```bash
|
|
787
|
+
dr relationship add api/<operation> realizes business/<service>
|
|
788
|
+
dr relationship add api/<document> realizes application/<service>
|
|
789
|
+
dr relationship add api/<schema> references data-model/<schema>
|
|
790
|
+
dr relationship add api/<operation> protected-by security/<resource>
|
|
791
|
+
dr relationship add api/<operation> supports motivation/<goal>
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
**Export Commands:**
|
|
795
|
+
|
|
796
|
+
```bash
|
|
797
|
+
dr export openapi --output api-spec.yaml
|
|
798
|
+
dr export openapi --layer api --format json --output api-spec.json
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
**Validation Commands:**
|
|
802
|
+
|
|
803
|
+
```bash
|
|
804
|
+
dr validate --layer api
|
|
805
|
+
spectral lint api-spec.yaml
|
|
806
|
+
swagger-cli validate api-spec.yaml
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
---
|
|
810
|
+
|
|
811
|
+
## Custom Extension Reference
|
|
812
|
+
|
|
813
|
+
Documentation Robotics defines custom OpenAPI extensions for cross-layer traceability:
|
|
814
|
+
|
|
815
|
+
```yaml
|
|
816
|
+
# Motivation Layer Links
|
|
817
|
+
x-supports-goals: [motivation/goal/id1, motivation/goal/id2]
|
|
818
|
+
x-fulfills-requirements: [motivation/requirement/id1]
|
|
819
|
+
x-governed-by-principles: [motivation/principle/id1]
|
|
820
|
+
x-constrained-by: [motivation/constraint/id1]
|
|
821
|
+
|
|
822
|
+
# Business and Application Layer Links — use dr relationship add (not x-* properties)
|
|
823
|
+
# dr relationship add api.<type>.<name> business.<type>.<name> --predicate realizes
|
|
824
|
+
# dr relationship add api.<type>.<name> application.<type>.<name> --predicate realizes
|
|
825
|
+
|
|
826
|
+
# Security Layer Links
|
|
827
|
+
x-security-resource: security/secure-resource/id
|
|
828
|
+
x-required-permissions: [users.read, users.write]
|
|
829
|
+
x-rate-limit:
|
|
830
|
+
requests: 100
|
|
831
|
+
window: 60s
|
|
832
|
+
|
|
833
|
+
# APM Layer Links
|
|
834
|
+
x-apm-business-metrics: [apm/metric/id1]
|
|
835
|
+
x-apm-sla-target-latency: "100ms"
|
|
836
|
+
x-apm-sla-target-availability: "99.9%"
|
|
837
|
+
x-apm-trace: true
|
|
838
|
+
x-apm-criticality: "high" # critical, high, medium, low
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
These extensions enable full traceability from API operations to business goals, requirements, security controls, and monitoring metrics.
|
|
842
|
+
|
|
843
|
+
---
|
|
844
|
+
|
|
845
|
+
## Summary
|
|
846
|
+
|
|
847
|
+
The API Layer is the **contract layer** - it defines HOW external consumers interact with your system. Every operation should:
|
|
848
|
+
|
|
849
|
+
1. Be linked to a business service (traceability)
|
|
850
|
+
2. Have clear request/response schemas
|
|
851
|
+
3. Define security requirements
|
|
852
|
+
4. Specify SLA targets for monitoring
|
|
853
|
+
5. Include examples for documentation and testing
|
|
854
|
+
|
|
855
|
+
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.
|