Skip to content

Releases: gpu-cli/openapi-to-rust

v0.6.0

Choose a tag to compare

@github-actions github-actions released this 13 Jul 04:22
833185d

What's Changed

  • feat(client): typed query parameter serialization (form/deepObject styles) (#27) by @lightsofapollo in #28

Full Changelog: v0.5.3...v0.6.0

v0.5.3

Choose a tag to compare

@github-actions github-actions released this 11 Jul 18:57

What's Changed

Full Changelog: v0.5.2...v0.5.3

v0.5.2

Choose a tag to compare

@github-actions github-actions released this 11 Jul 03:28

What's Changed

Full Changelog: v0.5.1...v0.5.2

v0.5.1

Choose a tag to compare

@github-actions github-actions released this 07 Jul 23:56

Full Changelog: v0.5.0...v0.5.1

v0.4.0

Choose a tag to compare

@github-actions github-actions released this 08 May 03:32
77023a2

What's Changed

  • fix(client): emit typed enum for const/enum on parameter schemas by @lightsofapollo in #13

Full Changelog: v0.3.0...v0.4.0

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 07 May 23:48
3e93ad3

What's Changed

Full Changelog: v0.2.1...v0.3.0

v0.2.1

Choose a tag to compare

@github-actions github-actions released this 07 May 19:25

Full Changelog: v0.2.0...v0.2.1

v0.2.0

Choose a tag to compare

@lightsofapollo lightsofapollo released this 07 May 19:22
260e48a

Breaking change. Generated method signatures change from HttpResult<T> to Result<T, ApiOpError<E>> so multi-response operations and typed error bodies work correctly. Closes #8.

What changed

  • ApiError<E> envelope always carries status + headers + raw body, with optional typed: Option<E> populated when the body matched a declared schema. You can now inspect what the server actually sent without modifying the generated code.
  • ApiOpError<E> = Transport(HttpError) | Api(ApiError<E>) is the new return-type wrapper for every generated operation method.
  • Per-operation error enums are emitted when an op declares non-2xx body schemas: {Op}ApiError { Status400(BadRequestBody), Status404(NotFoundBody), … }. Ops with no declared error schemas fall back to ApiOpError<serde_json::Value> so the body is still inspectable as JSON.
  • Always-on raw body capture — the response handler reads the body to a string before any typed parse, so deserialization failures preserve the bytes.
  • Root-cause fix for the original collision in #8: the inline-response naming function now uses the response status code, so a 200 + 400 spec no longer overwrites the 200 schema with the 400 schema in the registry.

Why no all-responses enum

A single enum Response { Status200(_), Status400(_) } would force every caller to match every variant for every call and lose Result ergonomics. Successes are Ok(T); errors are typed Err(ApiOpError<E>).

Migration

The HttpError::Http { ... } variant and from_status helper are removed from generated code (replaced by ApiError<E>). The is_client_error / is_server_error helpers move to ApiError<E>.

Old:

let result: Result<Foo, HttpError> = client.foo().await;
match result {
    Err(HttpError::Http { status, body, .. }) => { /* ... */ }
    /* ... */
}

New:

let result: Result<Foo, ApiOpError<FooApiError>> = client.foo().await;
match result {
    Err(ApiOpError::Api(e)) => {
        // e.status, e.headers, e.body always populated
        // e.typed: Option<FooApiError> when the body matched a declared schema
    }
    Err(ApiOpError::Transport(e)) => { /* network/timeout */ }
    /* ... */
}

Full discussion: issue #8 · PR: #9

v0.1.15

Choose a tag to compare

@lightsofapollo lightsofapollo released this 06 May 18:26

Two follow-ups to issue #7 that surfaced after 0.1.14:

  • anyOf with {"type": "null"} and 3+ variants previously panicked with "()" is not a valid Ident because the null branch produced a phantom () type alias. analyze_anyof_union now filters {"type": "null"} variants up front, mirroring the oneOf fix.
  • oneOf with an array variant whose items reduce to serde_json::Value (e.g. items: {}) previously emitted Vec<SerdeJsonValue>. The generator now emits Vec<serde_json::Value> (and Vec<Vec<serde_json::Value>>) as path tokens instead of mangling the :: into a single ident.

Fixes #7.

v0.1.14

Choose a tag to compare

@lightsofapollo lightsofapollo released this 06 May 06:11

Fix oneOf with {"type": "null"} variants (#7).

Previously, an inline oneOf: [{"type": "null"}, {"type": "string"}] schema generated an untagged enum with a phantom SerdeJsonValue(SerdeJsonValue) variant — a non-existent type produced by mangling serde_json::Value into a single ident. anyOf already handled the same shape correctly.

oneOf now matches anyOf:

  • oneOf: [Type, null] reduces to the non-null type with the property marked nullable (Option<T>).
  • oneOf with 3+ variants including {"type": "null"} filters the null branch out instead of leaking it through.
  • The generator emits serde_json::Value as a path defensively, so any future analyzer path that pushes it as a union variant target stays valid Rust.

Fixes #7.