Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.1]

### Breaking Changes

- Rust generated clients now expose backend-native header maps from
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
]

[workspace.package]
version = "0.2.0"
version = "0.2.1"
edition = "2024"
rust-version = "1.90"
description = "OpenAPI 3.x multi-language code generator"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OpenAPI Nexus transforms OpenAPI specifications into type-safe client libraries.
**Shell installer (no Rust toolchain needed):**

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-codegen-group/openapi-nexus/releases/download/0.2.0/openapi-nexus-installer.sh | sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-codegen-group/openapi-nexus/releases/download/0.2.1/openapi-nexus-installer.sh | sh
```

**Nightly build (latest main):**
Expand Down
2 changes: 1 addition & 1 deletion docs/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Shell installer (no Rust toolchain needed):**

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-codegen-group/openapi-nexus/releases/download/0.2.0/openapi-nexus-installer.sh | sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-codegen-group/openapi-nexus/releases/download/0.2.1/openapi-nexus-installer.sh | sh
```

**Nightly build (latest main):**
Expand Down
38 changes: 38 additions & 0 deletions docs/src/response_headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,44 @@ paths:
$ref: "#/components/headers/RetryAfter"
```

## Reading headers

Generated accessor names follow the operation and header names in the OpenAPI
document. This Rust example uses an accessor for each declared header and falls
back to the backend-native header map for an undeclared tracing header:

```rust
match api.create_resource(&request).await {
Ok(response) => {
let request_id = response.x_request_id_header();
let traceparent = response
.headers
.get("traceparent")
.and_then(|value| value.to_str().ok());

println!("request_id={request_id:?} traceparent={traceparent:?}");
}
Err(error) => {
let retry_after = error.retry_after_header().map(str::to_owned);

// Erase the payload type when only common response metadata is needed.
let error: ApiCallError = error.into();
let traceparent = error
.headers()
.and_then(|headers| headers.get("traceparent"))
.and_then(|value| value.to_str().ok());

eprintln!("retry_after={retry_after:?} traceparent={traceparent:?}");
}
}
```

In this example, `X-Request-Id` and `Retry-After` are declared in OpenAPI, so
the generator provides typed accessors. `traceparent` is undeclared and remains
available through the native header map. Match the operation-specific error
before converting it to `ApiCallError` when its decoded body is needed; see
[Generated Error Handling](rust_config.md#generated-error-handling).

## Generated access

| Generator | Successful response headers | Error response headers |
Expand Down
Loading