Skip to content

SDK behaviour

Read this before you ship an SDK, to know exactly how it will behave for your users. The contract is the same in all nine languages, each in its own idioms, and oryva's tests check every item against a stub server.

  • Auth: constructor arguments for each scheme the API offers, falling back to the env vars in spec-extensions.md. Each request uses its operation's security (else the API's): the first requirement the client has every credential for from arguments, else the first it completes from env vars, with all of that requirement's schemes sent together; else, when one alternative is empty ({}), no credentials. None met: raise before sending, naming what each alternative still lacks. security: [] sends no credentials, and a 401's hint lists every alternative. OAuth2 client credentials: fetch a token, cache it per scheme, refresh 60 s before expiry; the token URL can be overridden.
  • Environments: pick a named server (environment="sandbox") or pass a base URL; the env var overrides the default.
  • Retries: 408, 409, 429, 5xx and connection errors, exponential backoff with jitter, honour Retry-After (seconds or HTTP date, capped at 60 s). Default 2 retries, configurable per client and per request.
  • Idempotency: when the API declares an idempotency header, every non-GET request gets a fresh key, reused across its retries; callers can pass their own.
  • Per-request options: timeout, max retries, extra headers, extra query, extra body.
  • Omitted vs null: omitting an optional argument sends nothing; passing null sends null.
  • Forward compatibility: enums and discriminated unions accept values the SDK doesn't know, without raising; unknown object fields are kept. A discriminator value that several variants share decodes as the first of them.
  • Pagination: list methods return a page that exposes its items and the next page, and can be iterated to walk every item across pages.
  • Streaming: event-stream methods return an iterable of typed events that can be closed early.
  • Files: uploads accept bytes, paths and file objects; downloads return bytes and can stream to a file.
  • Raw responses: a way to get status, headers and the parsed body together.
  • Errors: one class per status family plus connection and timeout errors, carrying status, body, request id, and a message that says how to fix the problem.
  • Webhooks: client.webhooks.unwrap(body, headers) verifies the signature (5-minute tolerance) and returns the typed event; a bad signature raises a dedicated error.
  • Telemetry: a User-Agent of <name>-<language>/<version>. Debug logging of requests with credentials redacted, turned on by an env var <NAME>_LOG=debug.
  • Deprecation: deprecated methods still work and warn once.

Ready to publish

Each generated SDK directory, in every language, is a package you can publish as it is, with:

  • README.md, with these sections in this order: Install; Usage; Authentication (each scheme, with its client arguments and env vars); Environments; Methods (one client.<resource>.<method> heading per method, with its summary and an example call); Errors (the class for each status, connection and timeout errors, and how to catch one); Retries and timeouts; Pagination; Raw responses; anything the language adds (streaming, files, webhooks, logging); Development (how to run the tests); Releasing.
  • Tests for the language's own runner, one per method, needing no network or credentials. Each runs that method's README example against a mock transport that answers with the example response, then checks the request's method and path, and that the result equals the example parsed with the SDK's own types. Values come from the spec's example or examples on properties and parameters, else the default, else a placeholder of the right type. An example call passes required arguments and any optional one with a spec example. The README and the tests render the same call, so every README example is one the tests run.
  • Package metadata: name, version and description, and the license, repository and authors from oryva.yml, which oryva never makes up. Go has no such fields; pkg.go.dev reads the repository's LICENSE file.
  • .github/workflows/release.yml: on a v* tag, run the tests, build, and publish; the publishing guide has each language's registry and the secrets it needs. A tag other than v and the package's version fails the release. Two jobs split the work: one without publishing rights installs, tests and builds (from the lockfile with npm ci, uv run --locked or cargo --locked when the repository has one), and only the other can publish, with the package the first built (for crates.io it packs the source unbuilt; for Maven Central it builds and signs, without the tests, since only it gets the signing key). Where a registry refuses a package without a license, repository URL or authors and oryva.yml leaves it unset, the workflow's first step fails and names the key. Packagist publishes PHP tags itself through its GitHub hook, so the PHP workflow only runs the tests; the Go workflow asks the module proxy for the new version.
  • CHANGELOG.md, with an entry for each version oryva generate wrote. See CI and regeneration.