feat(calm-server): calm server validation against a custom pattern#2565
feat(calm-server): calm server validation against a custom pattern#2565aayush-razdan wants to merge 2 commits into
Conversation
|
|
d57f3c1 to
61f4b3b
Compare
61f4b3b to
95e2542
Compare
There was a problem hiding this comment.
Pull request overview
Adds support in calm-server for validating an architecture instance against a runtime-supplied custom pattern, addressing #2099 by introducing a new /calm/validate/with-pattern endpoint alongside the existing validation flow.
Changes:
- Added
POST /calm/validate/with-patternroute to validate an architecture JSON against a pattern JSON provided in the request body. - Expanded unit test coverage for both the existing validation endpoint and the new with-pattern endpoint, including additional error-path tests.
- Added documentation and test fixtures demonstrating the new endpoint’s request format.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| calm-server/test_fixtures/validation_route/valid_instantiation_with_pattern.json | Adds a fixture request payload containing both architecture and pattern as JSON-encoded strings. |
| calm-server/src/server/routes/validation-route.ts | Implements /with-pattern endpoint and adjusts error handling for validation failures. |
| calm-server/src/server/routes/validation-route.spec.ts | Refactors test app setup and adds tests for the new endpoint and additional failure scenarios. |
| calm-server/README.md | Documents the new validation endpoint usage with an example curl request. |
| calm-server/AGENTS.md | Updates endpoint inventory and adds an example request for /with-pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) => { | ||
| let architecture; | ||
| try { | ||
| architecture = JSON.parse(req.body.architecture); |
|
|
||
| let pattern; | ||
| try { | ||
| pattern = JSON.parse(req.body.pattern); |
| return res.status(400).type('json').send(new ErrorResponse(`The "$schema" field (${schema}) in the architecture does not match the "$id" field (${patternId}) in the pattern`)); | ||
| } | ||
|
|
||
| try { |
| } | ||
|
|
||
| try { | ||
| const outcome = await validate(architecture, pattern, undefined, this.schemaDirectory, true); |
|
|
||
| ### Validate Architecture against a Pattern | ||
|
|
||
| Validate a CALM architecture document against a pattern: |
rocketstack-matt
left a comment
There was a problem hiding this comment.
Please address copilot comments
|
@aayush-razdan are you able to take a look at the Copilot feedback? |
Yes, working on this. |
|
Closing due to inactivity - please reopen if you get the chance to update |
Description
Addresses #2099 - "Currently the CALM Validation of pattern instances is done against patterns that already exist in the project directory. It should be possible to pass in a pattern instance and the pattern to the validation in order for it to be validated."
This is now available through the endpoint /calm/validate/with-pattern
Type of Change
Affected Components
cli/)calm/)calm-ai/)calm-hub/)calm-hub-ui/)calm-server/)calm-widgets/)docs/)shared/)calm-plugins/vscode/)Commit Message Format ✅
Testing
Checklist