Skip to content

Release 1.0

Latest

Choose a tag to compare

@objecthub objecthub released this 16 Nov 15:23

First stable release of YamlKit, a YAML 1.2.2 parser and emitter for Swift with Codable support and no runtime dependencies.

Highlights

  • Standards-compliant. The parser passes all 402 cases of the official YAML test suite. The suite checks events, resolved values and emitter round trips.
  • Codable integration. YAMLDecoder and YAMLEncoder work like JSONDecoder and JSONEncoder. They support date, data and key strategies (including snake case and kebab case), sorted keys, and special handling for Date, Data (!!binary), URL and Decimal.
  • Readable output. The emitter writes idiomatic block-style YAML. It quotes strings only where necessary and has configurable indentation and line width.
  • Layered API. Each stage of the YAML processing model can be used on its own: text → tokens → events (YAML.parseEvents) → nodes (YAMLNode) → values. The same layers run in reverse for emitting.
  • Safe by default. Nesting depth is limited (512). Alias expansion is capped, which protects against "billion laughs" attacks. Duplicate mapping keys are rejected.

Features

  • Full YAML 1.2.2 syntax: anchors and aliases, multi-document streams, block and flow collections, all scalar styles, %YAML and %TAG directives, and complex keys
  • Core, JSON and failsafe schemas, plus a YAMLSchema protocol for custom schemas
  • Optional support for merge keys (<<)
  • Input in UTF-8, UTF-16 and UTF-32 with automatic detection (BOM and null patterns)
  • Errors with line and column. Decoding errors are mapped to DecodingError with the full coding path.
  • Swift 6 language mode with strict concurrency. All public types are Sendable.
  • Non-recursive scanner, parser and composer, so deeply nested and very large documents don't overflow the stack

Documentation

Requirements

  • Swift 6.0 or later
  • macOS 13, iOS 16, tvOS 16 or watchOS 9 and later

Installation

.package(url: "https://github.com/objecthub/swift-yamlkit.git", from: "1.0.0")