You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Frontend's responsibility is to read an input source and translate it into the universal CDD Intermediate Representation (IR).
60
59
61
-
***Static Analysis (AST-Driven)**: For `Rust` source code, the tool **does not** use dynamic reflection or execute the code. Instead, it reads the source files, generates an Abstract Syntax Tree (AST) using `ra_ap_syntax`, and navigates the tree to extract classes, structs, functions, type signatures, API client definitions, server routes, and docstrings.
60
+
***Static Analysis (AST-Driven)**: For `Rust` source code, the tool **does not** use dynamic reflection or execute the code. Instead, it reads the source files, generates an Abstract Syntax Tree (AST) using the `syn` crate, and navigates the tree to extract classes, structs, functions, type signatures, API client definitions, server routes, and docstrings.
62
61
***OpenAPI Parsing**: For OpenAPI and JSON Schema inputs, the parser normalizes the structure, resolving internal `$ref`s and extracting properties, endpoints (client or server perspectives), and metadata into the IR.
63
62
64
63
### 2. Intermediate Representation (IR)
@@ -74,15 +73,15 @@ By standardizing on a single IR (heavily inspired by OpenAPI / JSON Schema primi
74
73
75
74
The Backend's responsibility is to take the universal IR and generate valid target output. Emitters can be written to support various environments (e.g., Client vs Server, Web vs CLI).
76
75
77
-
***Code Generation**: Emitters iterate over the IR and generate idiomatic `Rust` source code using token replacement and syntax manipulation.
78
-
* A **Server Emitter** creates routing controllers and request-validation logic.
79
-
* A **Client Emitter** creates API wrappers, fetch functions, and response-parsing logic.
80
-
***Database & CLI Generation**: Emitters can also target ORM models or command-line parsers by mapping IR properties to database columns or CLI arguments.
76
+
***Code Generation**: Emitters iterate over the IR and generate idiomatic `Rust` source code utilizing the `quote` crate.
77
+
* A **Server Emitter** creates Actix-web routing controllers and request-validation logic.
78
+
* A **Client Emitter** creates Reqwest API wrappers, fetch functions, and response-parsing logic.
79
+
***Database & CLI Generation**: Emitters can also target Diesel ORM models or Clap command-line parsers by mapping IR properties to database columns or CLI arguments.
81
80
***Specification Generation**: Emitters translating back to OpenAPI serialize the IR into standard OpenAPI 3.2.0 JSON or YAML, rigorously formatting descriptions, type constraints, and endpoint schemas based on what was parsed from the source code.
82
81
83
82
## 🔄 Extensibility
84
83
85
-
Because of the IR-centric design, adding support for a new `Rust` framework (e.g., a new Client library, Web framework like Axum/Actix, or ORM like Diesel/SeaORM) requires minimal effort:
84
+
Because of the IR-centric design, adding support for a new `Rust` framework (e.g., a new Client library, Web framework, or ORM) requires minimal effort:
86
85
1.**To support parsing a new framework**: Write a parser that converts the framework's AST/DSL into the CDD IR. Once written, the framework can automatically be exported to OpenAPI, Client SDKs, CLI parsers, or any other existing output target.
87
86
2.**To support emitting a new framework**: Write an emitter that converts the CDD IR into the framework's DSL/AST. Once written, the framework can automatically be generated from OpenAPI or any other supported input.
88
87
@@ -91,4 +90,4 @@ Because of the IR-centric design, adding support for a new `Rust` framework (e.g
91
90
1.**A Single Source of Truth**: Developers should be able to maintain their definitions in whichever format is most ergonomic for their team (OpenAPI files, Native Code, Client libraries, ORM models) and generate the rest.
92
91
2.**Zero-Execution Parsing**: Ensure security and resilience by strictly statically analyzing inputs. The compiler must never need to run the target code to understand its structure.
93
92
3.**Lossless Conversion**: Maximize the retention of metadata (e.g., type annotations, docstrings, default values, validators) during the transition `Source -> IR -> Target`.
94
-
4.**Symmetric Operations**: An Endpoint in the IR holds all the information necessary to generate both the Server-side controller that fulfills it, and the Client-side SDK method that calls it.
93
+
4.**Symmetric Operations**: An Endpoint in the IR holds all the information necessary to generate both the Server-side controller that fulfills it, and the Client-side SDK method that calls it.
Copy file name to clipboardExpand all lines: LICENSE-MIT
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Copyright 2022–2025 Samuel Marks (for Offscale.io)
1
+
Copyright 2026 Samuel Marks (for Offscale.io)
2
2
3
3
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
To publish `cdd-rust`(and its sub-crates like `cdd-core` and `cdd-cli`) to crates.io, follow these steps:
6
6
7
-
1.Update the version in `Cargo.toml`.
8
-
2.Ensure you are logged into `cargo` with `cargo login`.
9
-
3.Run `cargo publish` in the root workspace, or specifically in `core` then `cli`.
7
+
1.**Login to crates.io:**
8
+
Ensure you have an account on [crates.io](https://crates.io/) and have created an API token.
9
+
Run `cargo login` and paste your token.
10
10
11
-
## Documentation
11
+
2.**Verify the Build:**
12
+
Ensure everything builds and tests pass.
13
+
```bash
14
+
cargo check
15
+
cargo test
16
+
```
12
17
13
-
To generate and publish the documentation:
18
+
3. **Publish Sub-crates First:**
19
+
Publish the dependencies in the correct order (e.g., `core` before `cli`).
20
+
```bash
21
+
cd core
22
+
cargo publish
23
+
cd ../cli
24
+
cargo publish
25
+
```
14
26
15
-
1. Run `make build_docs`.
16
-
2. The output will be in `target/doc/`.
17
-
3. Serve this locally with a static web server or push it to a hosting provider.
27
+
## Publishing Documentation
28
+
29
+
### To docs.rs (Automatically)
30
+
31
+
When you publish a crate to crates.io, its documentation is automatically built and hosted on [docs.rs](https://docs.rs). You do not need to do anything manually for this.
32
+
33
+
### To Your Own Server
34
+
35
+
To build the documentation as static HTML files for hosting on your own server (like GitHub Pages, Netlify, or AWS S3):
36
+
37
+
1. **Build Docs Locally:**
38
+
```bash
39
+
cargo doc --no-deps --document-private-items
40
+
```
41
+
2. **Locate the Output:**
42
+
The static HTML files will be located in the `target/doc` directory.
43
+
3. **Upload:**
44
+
You can copy this folder to any static web host. For example, using `scp`:
When `cdd-rust`generates an SDK (e.g., via `cdd-rust from_openapi to_sdk`), you can publish the generated Rust crate to Crates.io.
3
+
When using `cdd-rust`to build an SDK, keeping the generated client code synchronized with the source OpenAPI specification is crucial. The optimal strategy relies on a GitHub Actions cronjob.
4
4
5
-
## Automated Updates
5
+
## Updating the Generated Client SDK via GitHub Actions
6
6
7
-
You can set up a GitHub Action cron job to periodically fetch the latest OpenAPI specification from your server, run `cdd-rust from_openapi to_sdk`, and push the changes if they differ.
7
+
This workflow fetches the latest OpenAPI specification and regenerates the Rust client SDK automatically.
8
+
9
+
Create a `.github/workflows/update-sdk.yml` file in your client SDK repository:
0 commit comments