OapiCodemode.Proxy (oapi_codemode v0.2.1)

Copy Markdown View Source

The validating, credential-injecting request pipeline: match -> policy -> validate -> credentials -> execute -> normalize.

Requests come from the sandbox as JSON-shaped maps (string keys). Errors return %{phase: atom, message: String.t()} — phase-tagged so tool-layer error messages can say what failed without leaking internals.

Error messages crossing back to the sandbox are fixed strings wherever the underlying detail could embed a credential (transport failures, resolver reasons). The detail goes to Logger instead.

Summary

Types

ctx()

@type ctx() :: %{
  resolver: module(),
  context: map(),
  policy: :read_only | :all,
  req_options: keyword()
}

request_opts()

@type request_opts() :: %{required(String.t()) => term()}

Functions

request(entry, api_name, opts, ctx)

@spec request(
  %OapiCodemode.Registry.Entry{artifact: term(), config: term()},
  String.t(),
  request_opts(),
  ctx()
) ::
  {:ok,
   %{
     status: integer(),
     headers: %{required(String.t()) => String.t()},
     body: term()
   }}
  | {:error, %{phase: atom(), message: String.t()}}