Skip to content

Add syntax validation endpoint for FHIR Mapping Language (FML) content#4

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-3
Closed

Add syntax validation endpoint for FHIR Mapping Language (FML) content#4
Copilot wants to merge 2 commits intomainfrom
copilot/fix-3

Conversation

Copy link
Contributor

Copilot AI commented Sep 15, 2025

This PR adds comprehensive FML syntax validation functionality across all three packages in the FML Runner ecosystem, providing useful error messages when validation fails.

Changes Made

Core Library (fmlrunner)

  • Added FmlSyntaxValidationResult type with detailed error information including line numbers, column numbers, and error locations
  • Implemented validateSyntax() method in FmlCompiler class that performs syntax validation without full compilation
  • Added validateFmlSyntax() method to main FmlRunner class for external API access
  • Provides specific error messages for common issues like missing map declarations and empty content

REST API (fmlrunner-rest)

  • Added POST /api/v1/validate-fml-syntax endpoint that accepts FML content and returns FHIR-compliant OperationOutcome responses
  • Returns HTTP 200 for valid syntax with informational message
  • Returns HTTP 400 for invalid syntax with detailed error information including line/column locations
  • Updated OpenAPI specification with complete endpoint documentation and examples

MCP Interface (fmlrunner-mcp)

  • Added validate-fml-syntax tool for AI/LLM integration
  • Returns structured JSON responses with validation results, errors, warnings, and location information
  • Maintains consistency with existing MCP tool patterns

Usage Examples

REST API:

curl -X POST http://localhost:3000/api/v1/validate-fml-syntax \
  -H "Content-Type: application/json" \
  -d '{"fmlContent": "map \"test\" = \"test\"\ngroup Test(source src, target tgt) { src -> tgt; }"}'

Core Library:

const runner = new FmlRunner();
const result = runner.validateFmlSyntax(fmlContent);
if (!result.valid) {
  console.log(`Error at line ${result.lineNumber}: ${result.errors[0]}`);
}

Error Message Examples:

  • Empty content: "FML content cannot be empty"
  • Missing map declaration: "FML content must start with a map declaration (e.g., "map "url" = "name")"
  • Parse errors include line and column information when available

The implementation leverages the existing FML tokenizer and parser infrastructure to provide detailed syntax validation with helpful error messages, making it easier for users to identify and fix FML syntax issues.

Fixes #3.

Warning

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.sh
    • Triggering command: node ./report.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

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 FHIR Mapping Language (FML) content Sep 15, 2025
Copilot AI requested a review from litlfred September 15, 2025 17:48
@litlfred litlfred closed this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add syntax validation endoint

2 participants