Skip to content

Generate typed HTTP error responses#135

Merged
adamcavendish merged 1 commit into
mainfrom
adamcavendish/typed-http-error-responses
Jul 7, 2026
Merged

Generate typed HTTP error responses#135
adamcavendish merged 1 commit into
mainfrom
adamcavendish/typed-http-error-responses

Conversation

@adamcavendish

Copy link
Copy Markdown
Collaborator

Summary

  • Split generated operation responses into success-only return types and typed HTTP error surfaces across Rust, Go, Python, TypeScript Fetch, Java, and Kotlin
  • Preserve operation-specific error classification by OpenAPI response entry, including exact status, wildcard range, default, and unexpected non-2xx responses
  • Keep status, headers, raw bodies, and lazy/deferred typed body access available on generated HTTP errors
  • Add a typed HTTP error fixture, cross-language goldens, and runtime tests for HTTP error behavior

Why

Generated clients previously surfaced documented 4xx/5xx responses through the normal success path. That made an HTTP failure look like a successful operation result and allowed callers to accidentally treat failed creates as success. This changes generated semantics so normal returns mean HTTP success only.

Validation

  • cargo test --workspace --all-targets --quiet
  • cargo test --test typed_http_error_runtime -- --nocapture
  • cargo test --test jvm_http_error_runtime -- --nocapture
  • cargo test --test multipart_runtime_smoke -- --nocapture
  • UPDATE_GOLDEN=1 cargo test --test golden_tests_java_okhttp
  • UPDATE_GOLDEN=1 cargo test --test golden_tests_typescript_fetch
  • Golden tests for Go, Python httpx/requests, Rust reqwest/ureq/aioduct, Java, Kotlin, and TypeScript Fetch
  • Golden build scripts for Go, Python httpx/requests, Rust reqwest/ureq/aioduct, Java, Kotlin, and TypeScript Fetch
  • cargo fmt --all -- --check
  • git diff HEAD^ --check

@adamcavendish adamcavendish force-pushed the adamcavendish/typed-http-error-responses branch from ad86390 to 50605a2 Compare July 6, 2026 15:11
- Return or throw operation-specific errors for documented non-2xx responses
- Preserve status, headers, raw bodies, and lazy typed error-body decoding
- Regenerate cross-language goldens and add typed HTTP error runtime tests
@adamcavendish adamcavendish force-pushed the adamcavendish/typed-http-error-responses branch from 50605a2 to a58a129 Compare July 6, 2026 15:21
@adamcavendish adamcavendish merged commit 83ab4f0 into main Jul 7, 2026
25 checks passed
@adamcavendish adamcavendish deleted the adamcavendish/typed-http-error-responses branch July 7, 2026 01:54
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