Skip to main content

Module transport

Module transport 

Source
Expand description

The one hand-written part of the generated API client: it turns an OperationDescriptor plus typed input into an HTTP request, and the response back into a result (WP-21 R-21.1).

The generator (sdk/auth/tools/generate_clients.py) decides what exists and what it looks like; this module decides how it travels. It mirrors the TypeScript and Python transports rule for rule, and the recorded exchanges in sdk/auth/tester/fixtures/recorded-responses.json are replayed through all three:

  • path parameters are percent-encoded one segment at a time, and . or .. is refused, because a URL parser would otherwise collapse it and aim the request at a different route;
  • credentials only go to https, or to a loopback host for local development;
  • redirects are never followed, so a credential cannot be replayed to another origin;
  • input the descriptor does not declare is an error, not silently dropped or sent;
  • a credential goes only to an operation that lists that scheme;
  • errors carry the status, the server’s error code and the request id, never the request, a header or a token.

Structs§

ApiClientOptions
ApiCredentials
One credential per security scheme named in the contract. The transport picks what an operation accepts.
ApiResponseError
The service answered with a non-2xx status. It holds the status, the server’s error code and the request id, never the request, a header or a credential.
BodySpec
CallInput
What a method hands the transport: each group as a JSON object (or absent). Every group is optional here; each descriptor declares which are required.
CallOptions
Per-call settings. Build one and pass it with AuthApiClient::with_options.
ClientBasicCredential
ExcludedOperation
A contract operation the client has no method for, with the coded reason.
OperationDescriptor
What the generator knows about one operation. The transport reads nothing else about the contract.
Transport
Executes descriptors over one reqwest::Client that never follows a redirect.

Enums§

ApiError
BodyKind
ClientBasicSource
ClientErrorCode
HttpMethod
ResponseKind
Surface
TokenSource
A token, or a function that returns one on every call (so a refreshed token is picked up).

Functions§

authorization
Which Authorization header an operation gets, or none. Fails when it needs a credential that was not supplied.
build_path
The path of a call: the template with each parameter encoded. ., .. and an empty value are refused.
form_quote
application/x-www-form-urlencoded for one component: a space is +, *-._ and alphanumerics stay.
group
Serialize one parameter group (or a body) for CallInput.