Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 59 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ members = [
"cargo-progenitor",
"example-build",
"example-macro",
"example-wasm",
"progenitor",
"progenitor-client",
"progenitor-impl",
"progenitor-macro",
]

# example-wasm is excluded from workspace because it uses gloo-client feature
# which conflicts with other members using reqwest-client
exclude = ["example-wasm"]

resolver = "2"

[workspace.dependencies]
Expand Down Expand Up @@ -57,7 +60,7 @@ typify = { version = "0.5.0" }
# typify = { git = "https://github.com/oxidecomputer/typify" }
url = "2.5.7"
unicode-ident = "1.0.22"
uuid = { version = "1.19.0", features = ["serde", "v4"] }
uuid = { version = "1.19.0", features = ["serde", "v4", "js"] }

#[patch."https://github.com/oxidecomputer/typify"]
#typify = { path = "../typify/typify" }
Expand Down
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ Progenitor may fail for some OpenAPI documents. If you encounter a problem, you
can help the project by filing an issue that includes the OpenAPI document that
produced the problem.

## HTTP Backend

Progenitor supports two HTTP backends:

- `reqwest-client`: Uses [reqwest](https://crates.io/crates/reqwest) for HTTP operations. Works on native targets and WASM. Best for server-side applications and native CLI tools.

- `gloo-client`: Uses [gloo-net](https://crates.io/crates/gloo-net) for HTTP operations. Designed specifically for WASM/browser environments. Produces smaller bundles than reqwest and leverages the browser's native Fetch API.

Differences of `gloo-net` compared to `reqwest`:

- Only works on browser targets (`wasm32-unknown-unknown`)
- WebSocket uses `web_sys::WebSocket` directly instead of HTTP protocol upgrade
- Connection pooling, timeouts, and TLS are handled by the browser and not configurable in code

## Using Progenitor

There are three different ways of using the `progenitor` crate. The one you
Expand All @@ -38,12 +52,13 @@ You'll need to add the following to `Cargo.toml`:

```toml
[dependencies]
futures = "0.3"
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
reqwest = { version = "0.12", features = ["json", "stream"] }
progenitor-client = { git = "https://github.com/oxidecomputer/progenitor", features = ["reqwest-client"] }
serde = { version = "1.0", features = ["derive"] }
```

For the gloo backend (WASM/browser), use `features = ["gloo-client"]` instead:

In addition, if the OpenAPI document contains string types with the `format`
field set to `date` or `date-time`, include

Expand Down Expand Up @@ -131,20 +146,19 @@ You'll need to add the following to `Cargo.toml`:

```toml
[dependencies]
futures = "0.3"
progenitor-client = { git = "https://github.com/oxidecomputer/progenitor" }
reqwest = { version = "0.12", features = ["json", "stream"] }
progenitor-client = { git = "https://github.com/oxidecomputer/progenitor", features = ["reqwest-client"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[build-dependencies]
prettyplease = "0.2.22"
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
progenitor = { git = "https://github.com/oxidecomputer/progenitor", default-features = false }
serde_json = "1.0"
syn = "2.0"
```

(`chrono`, `uuid`, `base64`, and `rand` as above)
For the gloo backend, use `features = ["gloo-client"]` in the progenitor-client dependency.

(`chrono`, `uuid`, `base64`, and `rand` as above depending on your OpenAPI spec)

Note that `progenitor` is used by `build.rs`, but the generated code required
`progenitor-client`.
Expand All @@ -157,7 +171,7 @@ however, the most manual way to use Progenitor.

Usage:

```
```bash
cargo progenitor

Options:
Expand All @@ -169,13 +183,14 @@ Options:

For example:

```
```bash
cargo install cargo-progenitor
cargo progenitor -i sample_openapi/keeper.json -o keeper -n keeper -v 0.1.0
```

... or within the repo:
```

```bash
cargo run --bin cargo-progenitor -- progenitor -i sample_openapi/keeper.json -o keeper -n keeper -v 0.1.0
```

Expand Down Expand Up @@ -396,4 +411,4 @@ Currently, the generated code doesn't deal with request headers. To add default
.unwrap();

let client = Client::new_with_client(baseurl, client_with_custom_defaults);
```
```
2 changes: 1 addition & 1 deletion cargo-progenitor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default-run = "cargo-progenitor"

[dependencies]
progenitor = { workspace = true, default-features = false }
progenitor-client = { workspace = true }
progenitor-client = { workspace = true, features = ["reqwest-client"] }
progenitor-impl = { workspace = true }

anyhow = { workspace = true }
Expand Down
Loading