Add syntax validation endpoint for FML with detailed error reporting#17
Closed
Add syntax validation endpoint for FML with detailed error reporting#17
Conversation
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] add syntax validation endoint
Add syntax validation endpoint for FML with detailed error reporting
Sep 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a dedicated syntax validation endpoint for FHIR Mapping Language (FML) content, building on the foundation of PR #6 which introduced the complete FML compiler with tokenization and parsing capabilities.
Problem
The existing FML Runner only provided full compilation functionality, which meant developers had to wait for complete compilation to detect basic syntax errors. There was no lightweight way to validate FML syntax during development, making the authoring experience less efficient.
Solution
Added comprehensive syntax validation that leverages the existing tokenizer and parser to provide fast, detailed syntax checking without the overhead of full compilation.
Core Implementation
The new
validateSyntax()method inFmlCompilerperforms syntax-only validation:For invalid syntax, it provides precise error location:
REST API Endpoint
The new
POST /api/v1/validate-syntaxendpoint returns FHIR-compliant OperationOutcome responses:Response with validation errors:
{ "resourceType": "OperationOutcome", "issue": [ { "severity": "error", "code": "invalid", "diagnostics": "FML content cannot be empty", "location": ["line 1, column 1"] } ] }MCP Tool Integration
Added
validate-fml-syntaxtool for Model Context Protocol integration, enabling IDE and editor plugins to leverage syntax validation:{ "name": "validate-fml-syntax", "arguments": { "fmlContent": "map \"test\" = \"TestMap\"" } }Key Features
Validation Capabilities
The syntax validator detects:
Demo Output
The included demo shows real-time validation:
Benefits
This enhancement significantly improves the FML authoring experience by:
The syntax validation endpoint complements the existing compilation functionality, giving developers both fast syntax checking and comprehensive semantic validation options based on their needs.
Testing
Run the demo with:
node demo-syntax-validation.jsWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
scarf.shnode ./report.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.