Skip to content

feat: preserve generated response headers - #140

Merged
adamcavendish merged 1 commit into
mainfrom
adamcavendish/preserve-response-headers
Jul 31, 2026
Merged

feat: preserve generated response headers#140
adamcavendish merged 1 commit into
mainfrom
adamcavendish/preserve-response-headers

Conversation

@adamcavendish

Copy link
Copy Markdown
Collaborator

Summary

Preserves response headers consistently across every generated client and adds optional typed accessors for OpenAPI-declared headers.

Problem

Successful responses did not expose headers consistently, Rust error handling converted headers through a lossy string vector, and referenced response-header components were dropped during lowering. This made headers such as Retry-After unavailable or adapter-dependent.

Behavior

Situation Behavior
Successful or HTTP error response Retains the backend-native header collection
Undeclared header Remains available through the native/raw response
Declared string header Optional string accessor
Declared integer, number, or boolean header Optional typed accessor using canonical scalar wire syntax
Missing or malformed declared header Accessor returns its empty result without failing response handling
Colliding normalized header names Generates deterministic, collision-safe accessor names
Referenced or cyclic component header Resolves valid references and returns a lowering error for cycles

Compatibility

Rust generated response structs now include a native headers field, and ApiError::headers() returns the backend-native HeaderMap instead of Vec<(String, String)>. Python retains existing body-only methods and adds collision-safe *_with_http_info() methods. Browser Fetch visibility still follows CORS Access-Control-Expose-Headers.

No package version or release metadata changes are included.

Validation

  • cargo fmt --all -- --check
  • just clippy
  • just doc-check
  • just book
  • just test-all
  • just golden-check
  • just golden-build-all

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

@adamcavendish
adamcavendish force-pushed the adamcavendish/preserve-response-headers branch from 63f6a08 to d21b06e Compare July 31, 2026 08:15
- Retain backend-native response headers on successful and HTTP error paths
- Generate collision-safe typed accessors for declared scalar headers
- Resolve referenced response headers across OpenAPI 3.0, 3.1, and 3.2
- Cover malformed values, reference cycles, runtime behavior, and goldens
@adamcavendish
adamcavendish force-pushed the adamcavendish/preserve-response-headers branch from d21b06e to e709c1a Compare July 31, 2026 09:19
@adamcavendish
adamcavendish merged commit b0eb599 into main Jul 31, 2026
25 checks passed
@adamcavendish
adamcavendish deleted the adamcavendish/preserve-response-headers branch July 31, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant