{"id":47690628,"url":"https://github.com/samuelmarks/cdd-swift","last_synced_at":"2026-06-29T03:00:40.168Z","repository":{"id":340874693,"uuid":"1167265309","full_name":"SamuelMarks/cdd-swift","owner":"SamuelMarks","description":"OpenAPI ↔ Swift","archived":false,"fork":false,"pushed_at":"2026-06-24T00:50:41.000Z","size":915,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-24T02:23:19.541Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamuelMarks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-26T05:30:50.000Z","updated_at":"2026-06-24T00:50:45.000Z","dependencies_parsed_at":"2026-02-27T05:00:45.413Z","dependency_job_id":null,"html_url":"https://github.com/SamuelMarks/cdd-swift","commit_stats":null,"previous_names":["samuelmarks/cdd-swift"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/SamuelMarks/cdd-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Fcdd-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Fcdd-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Fcdd-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Fcdd-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamuelMarks","download_url":"https://codeload.github.com/SamuelMarks/cdd-swift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Fcdd-swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34911134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-02T15:35:29.602Z","updated_at":"2026-06-29T03:00:40.162Z","avatar_url":"https://github.com/SamuelMarks.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"cdd-swift\n============\n\n[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![interactive WASM web demo](https://img.shields.io/badge/interactive-WASM_web_demo-blue.svg)](https://offscale.io/wasm_web_demo)\n[![CI](https://github.com/SamuelMarks/cdd-swift/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-swift/actions)\n[![Test Coverage](https://img.shields.io/badge/test_coverage-98.65%25-brightgreen.svg)](#)\n[![Doc Coverage](https://img.shields.io/badge/doc_coverage-100.00%25-brightgreen.svg)](#)\n\n**Compiler Driven Development (CDD)** is a development approach designed to eradicate the disconnect between: API specifications; server implementations; client SDKs; and command-line tooling.\n\nUnlike traditional code generators—that treat outputs as disposable or read-only—CDD provides a **complete, standalone compiler** for each supported language. These compilers are fully CST-aware (Concreate Syntax Tree is a whitespace+comment aware Abstract Syntax Tree), allowing true bidirectional synchronization between existing hand-edited source code and OpenAPI specifications.\n\n---\n\n## 🏗️ The Standalone Compiler Architecture\n\nTraditional tools use naïve templating—if you regenerate, your custom code is overwritten.\n\nThe CDD ecosystem is fundamentally different. It utilizes language-specific, standalone compilers capable of full AST parsing, semantic diffing, and surgical patching.\n\n**The Core Guarantee:** Every part of the generated codebase is fully editable.\nYou are encouraged to open the generated routing files, model definitions, and CLI structures, and directly inject your business logic.\n\n- **When your specification changes**, the CDD compiler reads your code, builds an AST, diffs it against the new spec, and safely patches in new endpoints or fields without touching your custom logic.\n- **When your codebase changes**, the compiler reverse-engineers your structural updates back into a 100% accurate, authoritative OpenAPI specification.\n\n---\n\n## 🔄 The Bidirectional Synchronization Loop\n\n```mermaid\nflowchart TD\n    OAS[\"📄 OpenAPI v3 Spec\"] \u003c--\u003e CDD{\"⚙️ CDD Compiler\"}\n\n    CDD \u003c--\u003e Codebase\n\n    subgraph Codebase [\"💻 Application Codebase\"]\n        direction TB\n\n        subgraph Outputs [\"📦 Primary Outputs\"]\n            direction TB\n            CLI[\"⌨️ CLI Tooling\"]\n            SDK[\"📦 Client SDK\"]\n            Server[\"🖥️ Server\"]\n\n            %% Force vertical stacking inside the subgraph\n            CLI ~~~ SDK ~~~ Server\n        end\n\n        subgraph Core [\"🔗 Core Architecture\"]\n            direction TB\n            Models[\"🔗 Data Models\"]\n            Routes[\"🔀 API Routes\"]\n            Tests[\"🧪 Tests\"]\n\n            %% Force vertical stacking inside the subgraph\n            Models ~~~ Routes ~~~ Tests\n        end\n\n        Mocks[\"🎭 API Mocks / Fakes\"]\n\n        %% Simple dependency flow down the page\n        Outputs --\u003e Core\n        Tests --\u003e Mocks\n    end\n\n    style OAS fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px\n    style CDD fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px\n    style Codebase fill:#fafafa,stroke:#9e9e9e,stroke-width:2px,stroke-dasharray: 5 5\n    style Outputs fill:#e8f5e9,stroke:#43a047,stroke-width:2px\n    style Core fill:#fff3e0,stroke:#f57c00,stroke-width:2px\n```\n\nThe CDD lifecycle supports continuous evolution from any starting point:\n1. **Generate**: Scaffold servers, SDKs, or CLIs from a central specification.\n2. **Edit**: Developers write real, unconstrained code directly in the generated files.\n3. **Extract**: Reverse-compile the edited code to produce an updated OpenAPI spec.\n4. **Sync**: Apply new specification changes seamlessly into the existing, hand-edited codebase.\n\n---\n\n## 🌐 The Global Language Ecosystem\n\nEvery supported language operates on the same core CDD philosophies but is powered by a dedicated, native compiler tailored to that language's specific AST, idioms, and package management.\n\nAll implementations share a standardized CLI interface (`cdd [subcommand]`), acting as a universal toolchain.\n\n| Repository | Language | Client; Client CLI; Server | Extra features | Standards | CI Status |\n|---|---|---|---|---|---|\n| [`cdd-c`](https://github.com/SamuelMarks/cdd-c) | C (C89) | Client; Client CLI; Server | FFI | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-c/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-c/actions/workflows/ci.yml) |\n| [`cdd-cpp`](https://github.com/SamuelMarks/cdd-cpp) | C++ | Client; Client CLI; Server | Upgrades Swagger \u0026 Google Discovery to OpenAPI 3.2.0 | Google Discovery; Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-cpp/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-cpp/actions/workflows/ci.yml) |\n| [`cdd-csharp`](https://github.com/SamuelMarks/cdd-csharp) | C# | Client; Client CLI; Server | CLR | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-csharp/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-csharp/actions/workflows/ci.yml) |\n| [`cdd-go`](https://github.com/SamuelMarks/cdd-go) | Go | Client; Client CLI; Server | | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-go/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-go/actions/workflows/ci.yml) |\n| [`cdd-java`](https://github.com/SamuelMarks/cdd-java) | Java | Client; Client CLI; Server | | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-java/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-java/actions/workflows/ci.yml) |\n| [`cdd-kotlin`](https://github.com/offscale/cdd-kotlin) | Kotlin (ktor for Multiplatform) | Client; Client CLI; Server | Auto-Admin UI | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/offscale/cdd-kotlin/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/cdd-kotlin/actions/workflows/ci.yml) |\n| [`cdd-php`](https://github.com/SamuelMarks/cdd-php) | PHP | Client; Client CLI; Server | | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-php/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-php/actions/workflows/ci.yml) |\n| [`cdd-python`](https://github.com/offscale/cdd-python) | Python | N/A (server building blocks) | CLI ↔ SQL ↔ Pydantic ↔ docs ↔ JSON-schema | N/A | [![Linting, testing, coverage, and release](https://github.com/offscale/cdd-python/workflows/Linting,%20testing,%20coverage,%20and%20release/badge.svg)](https://github.com/offscale/cdd-python/actions) |\n| [`cdd-python-all`](https://github.com/offscale/cdd-python-all) | Python | Client; Client CLI; Server |  | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/offscale/cdd-python-client/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/cdd-python-all/actions/workflows/ci.yml) |\n| [`cdd-ruby`](https://github.com/SamuelMarks/cdd-ruby) | Ruby | Client; Client CLI; Server |  | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-ruby/actions/workflows/ci.yml) |\n| [`cdd-rust`](https://github.com/SamuelMarks/cdd-rust) | Rust | Client; Client CLI; Server |  | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/offscale/cdd-rust/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/cdd-rust/actions/workflows/ci.yml) |\n| [`cdd-sh`](https://github.com/SamuelMarks/cdd-sh) | Shell (/bin/sh) | Client; Client CLI; Server |  | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-sh/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-sh/actions/workflows/ci.yml) |\n| [`cdd-swift`](https://github.com/SamuelMarks/cdd-swift) | Swift | Client; Client CLI; Server |  | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![CI](https://github.com/SamuelMarks/cdd-swift/actions/workflows/ci.yml/badge.svg)](https://github.com/SamuelMarks/cdd-swift/actions/workflows/ci.yml) |\n| [`cdd-ts`](https://github.com/offscale/cdd-ts) | TypeScript | Client; Client CLI; Server | Auto-Admin UI; Angular; React; Vue; fetch; Axios; Node.js | Swagger 2.0 \u0026 OpenAPI 3.2.0 | [![Tests and coverage](https://github.com/offscale/cdd-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/cdd-ts/actions/workflows/ci.yml) |\n\n---\n\n## 🛠️ Universal CLI Toolchain\n\nA true ecosystem requires standardized tooling. Once a developer learns the CDD toolchain, they can synchronize architecture across the entire polyglot stack.\n\n### Global Arguments\n\n- `--help`: Print help information.\n- `--version`: Print version information.\n- `--input, -i` (or `-f`): Target file, directory, or OpenAPI spec.\n- `--output, -o`: Destination path for generation or sync.\n\n### Core Subcommands\n\n#### `from_openapi`\nGenerate Swift code from an OpenAPI document.\n\n```text\nUSAGE: cdd-swift from_openapi \u003csubcommand\u003e\n\nOPTIONS:\n  --version               Show the version.\n  -h, --help              Show help information.\n\nSUBCOMMANDS:\n  to_sdk (default)        Generate a Client SDK from an OpenAPI specification.\n  to_sdk_cli              Generate a Client SDK CLI from an OpenAPI\n                          specification.\n  to_server               Generate a Server stub from an OpenAPI specification.\n\n  See 'cdd-swift help from_openapi \u003csubcommand\u003e' for detailed help.\n```\n\n#### `from_openapi to_sdk`\nGenerate a Client SDK from an OpenAPI specification.\n\n```text\nUSAGE: cdd-swift from_openapi to_sdk [--input \u003cinput\u003e] [--input-dir \u003cinput-dir\u003e] [--output \u003coutput\u003e] [--no-github-actions] [--no-installable-package] [--tests] [--mcp]\n\nOPTIONS:\n  -i, --input \u003cinput\u003e     Path to the input OpenAPI JSON file.\n  --input-dir \u003cinput-dir\u003e Path to a directory containing OpenAPI specifications.\n  -o, --output \u003coutput\u003e   Path to the output directory. Defaults to current\n                          working directory.\n  --no-github-actions     Do not generate GitHub Actions workflow.\n  --no-installable-package\n                          Do not generate installable package scaffolding.\n  --tests                 Generate composable tests and mocks.\n  --mcp                   Generate Model Context Protocol (MCP) server and\n                          adapter.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `from_openapi to_sdk_cli`\nGenerate a Client SDK CLI from an OpenAPI specification.\n\n```text\nUSAGE: cdd-swift from_openapi to_sdk_cli [--input \u003cinput\u003e] [--input-dir \u003cinput-dir\u003e] [--output \u003coutput\u003e] [--no-github-actions] [--no-installable-package] [--tests] [--mcp]\n\nOPTIONS:\n  -i, --input \u003cinput\u003e     Path to the input OpenAPI JSON file.\n  --input-dir \u003cinput-dir\u003e Path to a directory containing OpenAPI specifications.\n  -o, --output \u003coutput\u003e   Path to the output directory. Defaults to current\n                          working directory.\n  --no-github-actions     Do not generate GitHub Actions workflow.\n  --no-installable-package\n                          Do not generate installable package scaffolding.\n  --tests                 Generate composable tests and mocks.\n  --mcp                   Generate Model Context Protocol (MCP) server and\n                          adapter.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `from_openapi to_server`\nGenerate a Server stub from an OpenAPI specification.\n\n```text\nUSAGE: cdd-swift from_openapi to_server [--input \u003cinput\u003e] [--input-dir \u003cinput-dir\u003e] [--output \u003coutput\u003e] [--no-github-actions] [--no-installable-package] [--tests] [--mcp]\n\nOPTIONS:\n  -i, --input \u003cinput\u003e     Path to the input OpenAPI JSON file.\n  --input-dir \u003cinput-dir\u003e Path to a directory containing OpenAPI specifications.\n  -o, --output \u003coutput\u003e   Path to the output directory. Defaults to current\n                          working directory.\n  --no-github-actions     Do not generate GitHub Actions workflow.\n  --no-installable-package\n                          Do not generate installable package scaffolding.\n  --tests                 Generate composable tests and mocks.\n  --mcp                   Generate Model Context Protocol (MCP) server and\n                          adapter.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `generate_openapi`\nGenerate an example OpenAPI JSON document from Swift builder.\n\n```text\nUSAGE: cdd-swift generate_openapi [--output \u003coutput\u003e]\n\nOPTIONS:\n  -o, --output \u003coutput\u003e   Path to the output JSON file. Prints to stdout if not\n                          provided.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `to_openapi`\nParse a Swift file to extract Codable models and generate OpenAPI JSON.\n\n```text\nUSAGE: cdd-swift to_openapi --input \u003cinput\u003e [--output \u003coutput\u003e]\n\nOPTIONS:\n  -i, --input \u003cinput\u003e     Path to the input Swift file.\n  -o, --output \u003coutput\u003e   Path to the output JSON file. Prints to stdout if not\n                          provided.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `merge_swift`\nMerge generated Swift code from an OpenAPI document into an existing Swift file.\n\n```text\nUSAGE: cdd-swift merge_swift --input \u003cinput\u003e --output \u003coutput\u003e\n\nOPTIONS:\n  -i, --input \u003cinput\u003e     Path to the input OpenAPI JSON file.\n  -o, --output \u003coutput\u003e   Path to the existing Swift file to merge into.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `to_docs_json`\nGenerate JSON documentation with code snippets for an OpenAPI specification.\n\n```text\nUSAGE: cdd-swift to_docs_json --input \u003cinput\u003e [--output \u003coutput\u003e] [--no-imports] [--no-wrapping]\n\nOPTIONS:\n  -i, --input \u003cinput\u003e     Path or URL to the input OpenAPI specification.\n  -o, --output \u003coutput\u003e   Path to the output JSON file. Prints to stdout if not\n                          provided.\n  --no-imports            If provided, omit the imports field in the code\n                          object.\n  --no-wrapping           If provided, omit the wrapper_start and wrapper_end\n                          fields in the code object.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `serve_json_rpc`\nExpose CLI interface as a JSON-RPC server\n\n```text\nUSAGE: cdd-swift serve_json_rpc [-p \u003cport\u003e|--port \u003cport\u003e] [-l \u003clisten\u003e|--listen \u003clisten\u003e]\n\nOPTIONS:\n  -p, --port \u003cport\u003e       Port to listen on (default: 8082)\n  -l, --listen \u003clisten\u003e   Host to listen on (default: 0.0.0.0)\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `mcp`\nStart the Model Context Protocol (MCP) server via stdio\n\n```text\nUSAGE: cdd-swift mcp\n\nOPTIONS:\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n#### `sync`\nBi-directional synchronization of OpenAPI models and Swift definitions.\n\n```text\nUSAGE: cdd-swift sync [--truth \u003ctruth\u003e] --input \u003cinput\u003e --output \u003coutput\u003e\n\nOPTIONS:\n  --truth \u003ctruth\u003e         Designate the single source of truth ('class',\n                          'sqlalchemy', 'function'). Currently defaults to\n                          'class'.\n  -i, --input \u003cinput\u003e     Path to the input Swift file containing the source of\n                          truth.\n  -o, --output \u003coutput\u003e   Path to the output OpenAPI JSON file to synchronize.\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n### Detail Features Beyond Common Subset\n\n- **Model Context Protocol (MCP):** Generates full MCP servers and adapters (`--mcp`) allowing LLMs and AI editors to introspect or call the API.\n- **Smart Merging (`merge-swift`):** AST-aware merging of generated Swift code into existing Swift files without overwriting handwritten logic.\n- **Vapor Server Stub:** Scaffolds a full, runnable Vapor-based HTTP server, complete with `Fluent` ORM for SQLite and automated API migrations.\n- **Test Generation (`--tests`):** Automatically generates mock instances, test doubles, and XCTVapor tests to establish behavioral correctness.\n- **SwiftSyntax Parsing:** Employs the robust `SwiftSyntax` framework to ensure high-fidelity, whitespace-preserving modifications and accurate Swift to OpenAPI reverse-generation.\n\n---\n\n## 🚀 The End of \"Spec Drift\"\n\nWith Compiler Driven Development, specifications and code are no longer loosely coupled artifacts. They are strict, isomorphic reflections of one another, maintained by dedicated standalone compilers.\n\nChoose your language ecosystem above and start treating your architecture as a seamlessly compiled, endlessly editable whole.\n\n---\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttps://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmarks%2Fcdd-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelmarks%2Fcdd-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmarks%2Fcdd-swift/lists"}