ApifyClient.Generator.Renderer (apify_client v1.0.0)

Copy Markdown View Source

oapi_generator renderer that makes the generated code idiomatic Elixir.

The Apify API speaks camelCase; the generated client speaks snake_case:

  • Schemas — struct fields, typespecs and __fields__/1 use snake_case. Each schema module also gets __json_names__/1, mapping every field to its name in the API, which the client uses to decode and encode bodies:

    def __json_names__(:t), do: [default_dataset_id: "defaultDatasetId", ...]
  • Operations — path parameters are snake_case arguments (actor_id) and query parameters are snake_case options (max_items: 10). The generated function translates options to the API's names itself, so the client receives wire-ready query params:

    query =
      for {key, name} <- [max_items: "maxItems", wait_for_finish: "waitForFinish"],
          Keyword.has_key?(opts, key),
          do: {name, Keyword.fetch!(opts, key)}
  • Paths — path parameters are URL-encoded (the stock renderer interpolates them raw, which breaks record keys with / or spaces).

Generation-time only

Runs under mix apify.gen only; lives in dev/ because it depends on the dev-only :oapi_generator.