Skip to content

0.2.0 - Typed composition and OpenAPI integration

Latest

Choose a tag to compare

@ajevans99 ajevans99 released this 11 Sep 18:02
· 10 commits to main since this release

Typed composition

  • allOf intersects types and combines compatible object fields while preserving original validation boundaries.
  • anyOf and oneOf retain a common Swift output type or generate nested public Sendable enums for different payload types.
  • Generated union cases follow branch order (option1, option2, ...); nested objects, arrays, nullable values, and references are supported.
  • not preserves the surrounding output type while enforcing the negated schema.
  • Structural $ref siblings now use the same output-shaping rules as allOf.
  • Requires swift-json-schema 0.13.2, which corrects schema-aware composition branch selection. Branches no longer match based only on successful Swift type parsing.

OpenAPI integration

The offline OpenAPISchemaGenerator adapter generates the supported JSON Schema subset of OpenAPI 3.1 JSON components.schemas, preserving original names, references, and identifier scopes.

The Style API example generates Swift and compiles a separate consumer covering shared typography/color definitions, allOf themes, same-output font unions, and typed ready/pending response variants.

This is not an HTTP client generator or full OpenAPI validator. YAML, OpenAPI 3.0, dynamic/recursive references, custom dialects, and OpenAPI-only schema keywords such as discriminator remain unsupported.

Package metadata

  • Added .spi.yml documentation targets for Swift Package Index.
  • Added CI, supported Swift versions, and supported platforms badges.
  • CI covers package suites, the build-plugin consumer, and the generated OpenAPI consumer on macOS and Linux.

Integrating the shared core

Custom frontends must emit all GeneratedSchema.declarations inside the same namespace as schema; the list can contain public enum declarations and private static helpers. The bundled macro, CLI, and plugin already do this.

.package(
  url: "https://github.com/ajevans99/swift-json-schema-codegen.git",
  from: "0.2.0"
)