Skip to content

feat(swift): Add Swift SDK implementation #4

@clemensv

Description

@clemensv

Summary

Add a Swift SDK for JSON Structure schema and instance validation.

Background

Swift is the primary language for Apple's ecosystem (iOS, macOS, watchOS, tvOS, visionOS) with 1.5B+ active devices. Mobile apps frequently need to validate API responses against schemas, making this a high-value addition to the SDK family.

Implementation Guide

Follow the SDK Guidelines document: SDK-GUIDELINES.md

This document contains:

  • Required components (SchemaValidator, InstanceValidator, ErrorCodes, JsonSourceLocator)
  • Complete type system reference (34 primitive types + compound types)
  • Keywords reference (what to implement, what NOT to implement)
  • Error codes reference (assets/error-messages.json)
  • Test assets for conformance testing
  • Conformance checklist

Requirements

Core Features

  • Schema Validation: Validate JSON Structure schema documents for conformance
  • Instance Validation: Validate JSON instances against JSON Structure schemas
  • Error Reporting: Line/column information for validation errors (when source JSON available)
  • Full Type Support: All 34 primitive and compound types from JSON Structure Core v0

Technical Requirements

  • Swift 5.9+ (for modern concurrency features)
  • Swift Package Manager (SPM) for distribution
  • Cross-platform: macOS, iOS, Linux, Windows
  • Use Foundation.JSONSerialization or Codable for JSON parsing
  • No Apple-only framework dependencies (pure Swift for portability)

Package Structure

swift/
 Package.swift
 README.md
 Sources/
    JSONStructure/
        SchemaValidator.swift
        InstanceValidator.swift
        Types.swift
        ErrorCodes.swift
        JsonSourceLocator.swift
        ValidationResult.swift
 Tests/
     JSONStructureTests/
         SchemaValidatorTests.swift
         InstanceValidatorTests.swift
         TestAssets.swift

CI/CD

  • GitHub Actions workflow with macOS runner (required for Swift)
  • Test matrix: Swift 5.9, 5.10 on macOS and Linux
  • Integration with shared test-assets/ for cross-SDK validation

Reference Materials

Acceptance Criteria

  • All test-assets pass validation
  • CI workflow passes on macOS and Linux
  • README with installation and usage examples
  • Conformance checklist completed (see SDK-GUIDELINES.md)
  • Published to Swift Package Index (or ready for publication)

Metadata

Metadata

Labels

copilotFor GitHub Copilot coding agent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions