Skip to content

Releases: ajevans99/swift-json-schema-codegen

0.2.0 - Typed composition and OpenAPI integration

Choose a tag to compare

@ajevans99 ajevans99 released this 11 Sep 18:02

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"
)

0.1.0 - Offline schema references

Choose a tag to compare

@ajevans99 ajevans99 released this 10 Sep 23:39

First tagged release of Swift JSON Schema Codegen, built on swift-json-schema 0.13.1.

Included

  • Attached @Schema macro with automatically derived tuple outputs.
  • Shared generation core, batch CLI, and SwiftPM build-tool plugin.
  • Offline local and cross-document $defs/$ref resolution, canonical and nested $id resources, static anchors, and strict JSON Pointers.
  • Original-source diagnostics for missing references, duplicate identifiers, and cycles; bounded expansion for large graphs.
  • Reference-sibling constraints preserve intersection semantics rather than overwriting referenced constraints.
  • Realistic, authored design-token, theme, and application-settings schemas with reusable typography, palettes, spacing, and example JSON payloads.

See the plugin example and README for usage and the supported-keyword matrix.

Requires Swift 6.1 or later. References never trigger implicit disk or network loads. Recursive/dynamic references, input composition, and structural siblings next to $ref remain explicit errors.

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